[R] round giving different results on Windows and Mac
Duncan Murdoch
murdoch.duncan at gmail.com
Sat Mar 10 01:48:53 CET 2012
On 12-03-09 4:34 PM, Ruth Ripley wrote:
> Dear all,
>
> I have been running some tests of my package RSiena on different
> platforms and trying to reconcile the results.
>
> With Mac, the commands
>
> options(digits=4)
> round(1.81652, digits=4)
>
> print 1.817
The value you're printing is 1.8165, so I believe Windows gets it right
using our "round-to-even" rule, but I'm not surprised that there are
differences. The value 1.8165 isn't exactly representable, so it's
somewhat random whether a system chooses to represent it slightly larger
or slightly smaller.
Duncan Murdoch
>
> With Windows, the same commands print 1.816
>
> I am not bothered which answer I get, but it would be nice if they were
> the same. A linux box agreed with the Mac.
>
> Mac sessionInfo():
> R version 2.14.2 (2012-02-29)
> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>
> locale:
> [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] RSiena_1.0.12.205
>
> loaded via a namespace (and not attached):
> [1] grid_2.14.2 lattice_0.20-0 Matrix_1.0-4 tools_2.14.2
>
> Windows (but 2.14.1patched was the same) sessionInfo():
> R version 2.15.0 alpha (2012-03-08 r58640)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_United Kingdom.1252
> [2] LC_CTYPE=English_United Kingdom.1252
> [3] LC_MONETARY=English_United Kingdom.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United Kingdom.1252
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> Any enlightenment would be gratefully received.
>
> Ruth
More information about the R-help
mailing list