Let's do some rounding
> round(-0.001, 2)
[1] 0
I receive zero.
Now in combination with sprintf
> sprintf("%f", round(-0.001,2))
[1] "-0.000000"
Why is there a minus sign? I expected 0.000000
.
$R --version
R version 2.13.1 (2011-07-08)
It's the nature of floating point numbers (IEEE 754), there is a -0
defined. See -0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With