hacking at gringer.org
2008-Sep-25 05:00 UTC
[Rd] Rounding error for high-precision numeric values (PR#13010)
Full_Name: David Hall (gringer) Version: 2.7.2 (2008-08-25) OS: Debian GNU/Linux (sid/lenny) Submission from: (NULL) (130.195.86.38) Following on from a conversation I had with someone on IRC about Java's handling of difficult floating point numbers and its comparison with R's handling, I observed a couple of values that appeared to have incorrect rounding (1.9400994884341946e25, 1.9400994884341945e25). R displays these values to 18 significant figures, but the last digit is incorrect (should be 5, displays 4). This is probably within the realm of "quirky things that we just have to live with". Here's how to reproduce the problem: $ echo -e "options(digits=22)\n1.9400994884341946e25\n1.9400994884341948e25" | R \ --vanilla R version 2.7.2 (2008-08-25) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R.> options(digits=22) > 1.9400994884341946e25[1] 1.940099488434194e+25> 1.9400994884341948e25[1] 1.940099488434195e+25>
Maybe Matching Threads
- numeric (decimal) WITH precision and scale at generate scaffold time?
- summary.default rounding on numeric seems inconsistent with other R behaviors
- summary.default rounding on numeric seems inconsistent with other R behaviors
- Automatic rounding of values after factors , converted to numeric, are multipled by a real number
- summary.default rounding on numeric seems inconsistent with other R behaviors