Skip to content
Prev 29066 / 63424 Next

significant digits (PR#9682)

pmc1 at cornell.edu wrote:
That specification doesn't make sense.  There is no "number of decimal 
places passed to it".  What sprintf() sees below is identical to what it 
would see if you called

sprintf("%f", 0.9)

because signif(0.90, digits=2) == 0.9.  Those two objects are identical.
Maybe not what you desired, but certainly reasonable behaviour.
As far as I know, rounding is fine in Windows:

 > round(1:10 + 0.5)
 [1]  2  2  4  4  6  6  8  8 10 10

looks okay to me.  If you want biased rounding instead (getting 2:11 as 
output), simply use trunc(x + 0.5) instead of round(x).

Duncan Murdoch