[Rd] Representation of floating point numbers (PR#1281)

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Thu, 24 Jan 2002 12:20:41 +0100 (MET)


On Thu, 24 Jan 2002 theis@statistik.uni-dortmund.de wrote:

> Full_Name: Winfried Theis
> Version: 1.4.0
> OS: Linux
> Submission from: (NULL) (129.217.207.135)
>
>
> Hello!
>
> During an error search I stumbled across the following:
> If I do
> > options(digits=22)
> and then type in e.g. 0.1 I get:
> > 0.1
> [1] 0.1000000000000000055511
>
> I hope there is some other way to correct this, than rounding to 12 digits
> or something similar. I tested it on a Sun and under Windows as well and it
> is the same on all systems.

0.1 cannot be represented exactly in binary arithmetic. You asked for the
representation to 22 digits, and at most 17 are used in IEEE arithmetic.

This is not a bug in R, which does not claim to have arbitrary precision.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._