[Rd] Inconsistent IEEE 754/IEC 60559 rounding behavior (PR#8452)
Micah_Altman@harvard.edu
Micah_Altman at harvard.edu
Thu Dec 29 22:10:30 CET 2005
Full_Name: Micah Altman
Version: 2.2
OS: Windows/Linux (RHELv3)
Submission from: (NULL) (71.243.63.53)
Documentation for round()/signif() indicates that IEC 60559 standard is used,
"_go to the even digit_" is used for rounding off a 5. However, signif(),
round() and sprintf() do not behave consistently -- rounding using round()
follows this rule, signif() does not, and sprintf() follows the rule on Linux
but not on Windows():
> version
_
platform x86_64-redhat-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 2
minor 2.0
year 2005
month 10
day 06
svn rev 35749
language R
> sessionInfo()
R version 2.2.0, 2005-10-06, x86_64-redhat-linux-gnu
attached base packages:
[1] "methods" "stats" "graphics" "grDevices" "utils" "datasets"
[7] "base"
> sprintf("%#.1g",as.double(0.25))
[1] "0.2"
> round(.25,digits=1)
[1] 0.2
> signif(.25,digits=1)
[1] 0.3
> version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 2.0
year 2005
month 10
day 06
svn rev 35749
language R
> sessionInfo()
R version 2.2.0, 2005-10-06, i386-pc-mingw32
attached base packages:
[1] "methods" "stats" "graphics" "grDevices" "utils" "datasets"
"base"
> sprintf("%#.1g",as.double(0.25))
[1] "0.3"
> round(.25,digits=1)
[1] 0.2
> signif(.25,digits=1)
[1] 0.3
>
More information about the R-devel
mailing list