10 Nov 2011 19:31
Decimal numbers
Andrej Kastrin <andrej.kastrin <at> yahoo.com>
2011-11-10 18:31:49 GMT
2011-11-10 18:31:49 GMT
Dear all, I'm a 2nd day METAPOST user. I wonder how to get a number rounded to a desired number of decimal places. A minimal example is pasted below. beginfig(1); xmax:=10; ux:=0.5cm; drawarrow (0,0)*ux..(xmax+0.7,0)*ux; for i=0 upto xmax: draw (i,-0.05)*ux -- (i,0.05)*ux; label.bot(decimal(i/10), (i,0)*ux); endfor; endfig; end The labels in the example above are as follows: "0, 0.1, 0.2,..., 0.9, 1" but the desired output is: "0.0, 0.1, 0.2,..., 0.9, 1.0" or even better: ".0, .1, .2,..., .9, 1.0" Thanks in advance for any pointers and/or suggestions.(Continue reading)
RSS Feed