On 19 May 2007 at 22:40, Zack Weinberg wrote:
| Package: r-base-core
| Version: 2.5.1~20070513-1
| Severity: normal
| 
| R's "format" function (and all other means of printing numbers) seem to
| round off at 14 decimal places, even if specifically asked for more
| precision.  This is a problem when trying to work with numerical algorithms
| that require things like 'the next representable number after X', as for
| double precision, the difference is generally on order of 10^-17.
| 
| Consider:
| 
| > X = 0.37
| > Xup = X + 5.5511152312578e-17 # this is the difference between X and
|                                 # the next larger representable number
| > Xup == X
| [1] FALSE

This one is key. The floating point representation is different. That matters.

| > Xup
| [1] 0.37
| > format(Xup, digits=20)
| [1] "0.37"
| 
| dump() is also affected by this bug, but (thankfully) save() is not, even
| in ASCII mode.

I don't think this is a bug. Did you see FAQ entriy 7.31:

7.31 Why doesn't R think these numbers are equal?
=================================================

The only numbers that can be represented exactly in R's numeric type are
integers and fractions whose denominator is a power of 2.  Other numbers
have to be rounded to (typically) 53 binary digits accuracy.  As a result,
two floating point numbers will not reliably be equal unless they have been
computed by the same algorithm, and not always even then.  For example

     R> a <- sqrt(2)
     R> a * a == 2
     [1] FALSE
     R> a * a - 2
     [1] 4.440892e-16

   The function `all.equal()' compares two objects using a numeric
tolerance of `.Machine$double.eps ^ 0.5'.  If you want much greater
accuracy than this you will need to consider error propagation carefully.

   For more information, see e.g. David Goldberg (1991), "What Every
Computer Scientist Should Know About Floating-Point Arithmetic", _ACM
Computing Surveys_, *23/1*, 5-48, also available via
`http://docs.sun.com/source/806-3568/ncg_goldberg.html'.



There is no claim that print() should show abitrary deltas to a given float.
Wishlist item at best, I think. What is your view?

Dirk

| 
| -- System Information:
| Debian Release: lenny/sid
|   APT prefers unstable
|   APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
| Architecture: i386 (i686)
| 
| Kernel: Linux 2.6.18-4-686 (SMP w/2 CPU cores)
| Locale: LANG=en_US, LC_CTYPE=en_US (charmap=UTF-8)
| Shell: /bin/sh linked to /bin/bash
| 
| Versions of packages r-base-core depends on:
| ii  atlas3-base [libblas.so.3 3.6.0-20.6     Automatically Tuned Linear 
Algebra
| ii  libbz2-1.0                1.0.3-6        high-quality block-sorting file 
co
| ii  libc6                     2.5-7          GNU C Library: Shared libraries
| ii  libgfortran1              4.1.2-7        Runtime library for GNU Fortran 
ap
| ii  libice6                   1:1.0.3-2      X11 Inter-Client Exchange library
| ii  libjpeg62                 6b-13          The Independent JPEG Group's 
JPEG 
| ii  libpaper-utils            1.1.21         Library for handling paper 
charact
| ii  libpcre3                  6.7-1          Perl 5 Compatible Regular 
Expressi
| ii  libpng12-0                1.2.15~beta5-2 PNG library - runtime
| ii  libreadline5              5.2-2          GNU readline and history 
libraries
| ii  libsm6                    2:1.0.3-1      X11 Session Management library
| ii  libx11-6                  2:1.0.3-7      X11 client-side library
| ii  libxt6                    1:1.0.5-2      X11 toolkit intrinsics library
| ii  perl                      5.8.8-7        Larry Wall's Practical 
Extraction 
| ii  refblas3 [libblas.so.3]   1.2-8          Basic Linear Algebra Subroutines 
3
| ii  tcl8.4                    8.4.12-1.1     Tcl (the Tool Command Language) 
v8
| ii  tk8.4                     8.4.12-1       Tk toolkit for Tcl and X11, v8.4 
-
| ii  unzip                     5.52-9         De-archiver for .zip files
| ii  zip                       2.32-1         Archiver for .zip files
| ii  zlib1g                    1:1.2.3-15     compression library - runtime
| 
| Versions of packages r-base-core recommends:
| ii  r-base-dev              2.5.1~20070513-1 GNU R installation of auxiliary 
GN
| ii  r-recommended           2.5.1~20070513-1 GNU R collection of recommended 
pa
| 
| -- no debconf information
| 

-- 
Hell, there are no rules here - we're trying to accomplish something. 
                                                  -- Thomas A. Edison


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to