Hi Folks, With a bit of experimentation I have determined (I think) that on my R implementation the largest positive integer that is exactly represented is (2^53 - 1), based on> (((2^53)-1)+1) - ((2^53)-1)[1] 1> ((2^53)+1) - (2^53)[1] 0 System: platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 1 minor 6.1 year 2002 month 11 day 01 language R Is there any other way to determine this sort of information? With thanks, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 167 1972 Date: 13-Aug-03 Time: 13:55:25 ------------------------------ XFMail ------------------------------
On Wed, 2003-08-13 at 07:55, Ted.Harding at nessie.mcc.ac.uk wrote:> Hi Folks, > With a bit of experimentation I have determined (I think) > that on my R implementation the largest positive integer > that is exactly represented is (2^53 - 1), based on > > > (((2^53)-1)+1) - ((2^53)-1) > [1] 1 > > ((2^53)+1) - (2^53) > [1] 0 > > System: > platform i686-pc-linux-gnu > arch i686 > os linux-gnu > system i686, linux-gnu > status > major 1 > minor 6.1 > year 2002 > month 11 > day 01 > language R > > Is there any other way to determine this sort of information? > > With thanks, > Ted.Ted, See ?.Machine No experimentation required :-) HTH, Marc Schwartz
Thanks to James Holtman for the confirmation of the IEEE definition, and to Marc Schwartz and Roger Koenker for pointing out ".Machine" which I had not been aware of! For the latter, the information I wanted is in> .Machine$double.digits[1] 53 so that the largest integer exactly represented is indeed 2^53 -1. Best wishes to all, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 167 1972 Date: 13-Aug-03 Time: 14:48:48 ------------------------------ XFMail ------------------------------
1e100 is just one example of much bigger number that is exactly represented (in floating point). But of course> 1e100+1 - 1e100[1] 0 You mean the biggest number such that adding one changes the result? I should be extremely careful with> print( 9007199254740994, digits=20)[1] 9007199254740994> print( 9007199254740994-1, digits=20)[1] 9007199254740992 Here subtracting one makes a difference of two ... but the numbers look like integers. Simon Fear Senior Statistician Syne qua non Ltd Tel: +44 (0) 1379 644449 Fax: +44 (0) 1379 644445 email: Simon.Fear at synequanon.com web: http://www.synequanon.com Number of attachments included with this message: 0 This message (and any associated files) is confidential and\...{{dropped}}
On Wed, 13 Aug 2003 Ted.Harding at nessie.mcc.ac.uk wrote:> Hi Folks, > With a bit of experimentation I have determined (I think) > that on my R implementation the largest positive integer > that is exactly represented is (2^53 - 1), based on > > > (((2^53)-1)+1) - ((2^53)-1) > [1] 1 > > ((2^53)+1) - (2^53) > [1] 0 >The variable .Machine contains this sort of thing. The largest exactly represented integer is .Machine$integer.max and the largest integer exactly represented as a double will be 2^.Machine$double.digits-1 I believe the floating point formats are the same on all versions of R at the moment (though the integer formats might not be) -thomas
(Ted Harding) <Ted.Harding at nessie.mcc.ac.uk> writes:> With a bit of experimentation I have determined (I think) > that on my R implementation the largest positive integer > that is exactly represented is (2^53 - 1), based on > > > (((2^53)-1)+1) - ((2^53)-1) > [1] 1 > > ((2^53)+1) - (2^53) > [1] 0Those "integer" values are being silently converted to double precision so what you are determining is the relative machine precision for doubles. Use .Machine$integer.max instead. On your platform it will probably be 2^31-1> .Machine$integer.max[1] 2147483647> log(.Machine$integer.max, 2)[1] 31> 2^31-1[1] 2147483647> log(.Machine$double.eps, 2)[1] -52> log(.Machine$double.neg.eps, 2)[1] -53