How to truncate/round-off decimal numbers?



Hi,

I want to truncate every number to 2 digits after the decimal point. I
tried the following but it doesnt work.

a = 2
b = 3
round(a*1.0 / b,2)
0.67000000000000004

Inspite of specifying 2 in 2nd attribute of round, it outputs all the
digits after decimal.
.



Relevant Pages

  • Re: 1-0.999.... = ?
    ... specifying a particular Turing machine. ... determined whether the Turing machine halted, ... A Brouwerian question about the digits of pi ... the determination of the individual ...
    (talk.origins)
  • Re: sprintf formatting question
    ... % Matlab documentation says: ... % A digit string including a period specifying the number ... Because for the g format specifier, the 5 specifies the total number of ... significant digits. ...
    (comp.soft-sys.matlab)
  • Re: dcolumn troubles - solved
    ... Oops, the first example is 'wrong', officially it should be like this: ... If you set the header wider, you will see this, like in this version: ... I have made a fix: first to get the variable transfered in the newcolumntype command, then to ask for 2 digits on the left, 5 digit on the right by specifying d, and then realigning the header as you did in the other columns: ...
    (comp.text.tex)
  • Fixed number of digits printing of integers (ex: 0001 to 0100)
    ... automatically just by specifying in a variable the number of desired ... I thought about printing to a variable using for example %4d and then ... number of digits I want. ... Prev by Date: ...
    (comp.lang.c)
  • Re: dcolumn troubles - solved
    ... Laszlo Domokos wrote: ... luckily it did not make any difference, I have specified 11 digits after ... If you set the header wider, ... the right by specifying d(two on the left is needed for the ...
    (comp.text.tex)