theis@statistik.uni-dortmund.de
2002-Jan-24 10:46 UTC
[Rd] Representation of floating point numbers (PR#1281)
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. Regards, Winfried Theis -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ripley@stats.ox.ac.uk
2002-Jan-24 11:20 UTC
[Rd] Representation of floating point numbers (PR#1281)
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hy everybody, if I use round function with numbers bigger than 2147483648 (at least in my PC running linux) I got> round(2147483648)[1] -2147483648>trunc, floor and ceiling work fine> trunc(2147483648)[1] 2147483648> ceiling(2147483648)[1] 2147483648> floor(2147483648)[1] 2147483648>Is this a bug? If not, I suggest that round give back NA or NaN in these cases. best, Claudio Agostinelli -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
theis@statistik.uni-dortmund.de
2002-Jan-24 13:06 UTC
[Rd] Representation of floating point numbers (PR#1281)
Dear Prof. Ripley, On 24-Jan-02 Prof Brian Ripley wrote:> > 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. >Okay, I do not expect arbitrary precision, but maybe a warning in some way would be in order, to tell non-experts, what can be expected... As I said I came across this, when I searched for an error and this might be the reason for it. When comparing distances in one dimension within the sequence seq(0,1,by=0.1), I found that R does not take the distances between (0.3, 0.5) and (0.5,0.7) to be equal.> abs(0.5-0.3)==abs(0.5-0.7)[1] FALSE Checking this now a bit closer with your information I found:> round(abs(0.5-0.3),digits=17)==round(abs(0.5-0.7),digits=17)[1] FALSE> round(abs(0.5-0.3),digits=16)==round(abs(0.5-0.7),digits=16)[1] TRUE Would it be possible to restrict "==" as well to the maximum number of digits used in the arithmetics? It would be very convenient to get the expected result from such a comparison. Thank you -- and of course the whole core-team -- for your efforts to make this great software! Regards, Winfried Theis ---------------------------------- E-Mail: Winfried Theis <theis@statistik.uni-dortmund.de> Date: 24-Jan-02 Time: 12:50:35 Dipl.-Math. Winfried Theis, Fachbereich Statistik, Graduiertenkolleg "Angewandte Statistik" Universität Dortmund, 44221 Dortmund Tel.: +49-231-755-5903 FAX: +49-231-755-4387 ---------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ripley@stats.ox.ac.uk
2002-Jan-24 13:27 UTC
[Rd] Representation of floating point numbers (PR#1281)
On Thu, 24 Jan 2002, Winfried Theis wrote:> Dear Prof. Ripley, > > On 24-Jan-02 Prof Brian Ripley wrote: > > > > 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. > > > Okay, I do not expect arbitrary precision, but maybe a warning in some way > would be in order, to tell non-experts, what can be expected... > > As I said I came across this, > when I searched for an error and this might be the reason for it. When comparing > distances in one dimension within the sequence seq(0,1,by=0.1), I found that R > does not take the distances between (0.3, 0.5) and (0.5,0.7) to be equal. > > > abs(0.5-0.3)==abs(0.5-0.7) > [1] FALSE > > Checking this now a bit closer with your information I found: > > round(abs(0.5-0.3),digits=17)==round(abs(0.5-0.7),digits=17) > [1] FALSE > > round(abs(0.5-0.3),digits=16)==round(abs(0.5-0.7),digits=16) > [1] TRUE > > Would it be possible to restrict "==" as well to the maximum number of digits > used in the arithmetics? It would be very convenient to get the expected result > from such a comparison.There is a function all.equal provided for this purpose: it is a misuse of ==. -- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
theis@statistik.uni-dortmund.de
2002-Jan-24 13:44 UTC
[Rd] Representation of floating point numbers (PR#1281)
On 24-Jan-02 Prof Brian Ripley wrote:> > There is a function all.equal provided for this purpose: it is a misuse of > ==.But there is no hint or note on the "Comparisons" help page concerning this problem. If it is a misuse one should be warned against it. Winfried Theis ---------------------------------- E-Mail: Winfried Theis <theis@statistik.uni-dortmund.de> Date: 24-Jan-02 Time: 13:54:53 Dipl.-Math. Winfried Theis, Fachbereich Statistik, Graduiertenkolleg "Angewandte Statistik" Universität Dortmund, 44221 Dortmund Tel.: +49-231-755-5903 FAX: +49-231-755-4387 ---------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._