Bugzilla – Bug 14491
strange rounding with the "digits" option
Last modified: 2011-03-05 17:40:55 UTC
> 6.93 - as I expect
> 7.93 - surprising
Why is 7.93 not printed as 7.9? It seems that the digit before the decimal place influences the rounding: for digits up to 6, the rounding is as I expect; for digits over 7, it rounds up, which surprises me. Another surprising case:
 7.9 - as I expect
 8 - surprising
There's been a an R-devel conversation about this,
a thread, starting at
The bug is in scientific() in src/main/format.c
and Petr is repeating part of my analysis and gives some further details.
IMO, it *is* a bug and should be fixed, even though it will mean changing R outputs in a few somewhat rare cases.
(In reply to comment #1)
> There's been a an R-devel conversation about this,
> a thread, starting at
> The bug is in scientific() in src/main/format.c
> and Petr is repeating part of my analysis and gives some further details.
> IMO, it *is* a bug and should be fixed, even though it will mean changing R
> outputs in a few somewhat rare cases.
> Martin Maechler
Petr Savicky and I have investigated and tested things, offline,
and thanks to his contributions, I've now committed a fix ...
which also addresses a long-standing misfeature for the case
digits >= 16 (which ?print.default *did* warn about).
Hence this should be fixed in "R-devel" i.e. pre-2.13.0
from svn revision 54672