From savicky at cs.cas.cz  Wed May 23 19:22:47 2007
From: savicky at cs.cas.cz (Petr Savicky)
Date: Wed, 23 May 2007 19:22:47 +0200
Subject: [Rd] R 2.5.0 refuses to print enough digits to recover exact
	floating point values
In-Reply-To: <20070523165523.GA23733@cs.cas.cz>
References: <eb97335b0705220013m6f3e137cp147d429c46717e24@mail.gmail.com>
	<4652C19F.1040509@statistik.uni-dortmund.de>
	<eb97335b0705220849l624d8cai6e49e37e2565ab81@mail.gmail.com>
	<46540A76.2080909@statistik.uni-dortmund.de>
	<20070523165523.GA23733@cs.cas.cz>
Message-ID: <20070523172247.GB23733@cs.cas.cz>

This is an addition to my previous message.

16 digits are indeed not sufficient to represent a double
value exactly. The next table is calculated in bc calculator.
It shows that if we restrict (or round) double values
to 16 decadic digits then from 4 to 5 consecutive distinct
double values get the same 16 digit decadic code.

1.234567890123456  a 16-digit number for comparison
1.0000000000000000000000000000     1 + 0*2^(-52)
1.0000000000000002220446049250     1 + 1*2^(-52)
1.0000000000000004440892098500     1 + 2*2^(-52)
1.0000000000000006661338147750     1 + 3*2^(-52)
1.0000000000000008881784197001     1 + 4*2^(-52)
1.0000000000000011102230246251     1 + 5*2^(-52)
1.0000000000000013322676295501     1 + 6*2^(-52)
1.0000000000000015543122344752     1 + 7*2^(-52)
1.0000000000000017763568394002     1 + 8*2^(-52)
1.0000000000000019984014443252     1 + 9*2^(-52)
1.0000000000000022204460492503     1 + 10*2^(-52)
1.0000000000000024424906541753     1 + 11*2^(-52)
1.0000000000000026645352591003     1 + 12*2^(-52)
1.0000000000000028865798640254     1 + 13*2^(-52)
1.0000000000000031086244689504     1 + 14*2^(-52)
1.0000000000000033306690738754     1 + 15*2^(-52)
1.0000000000000035527136788005     1 + 16*2^(-52)
1.0000000000000037747582837255     1 + 17*2^(-52)
1.0000000000000039968028886505     1 + 18*2^(-52)
1.0000000000000042188474935755     1 + 19*2^(-52)

Petr.



[Rd] R 2.5.0 refuses to print enough digits to recover exact floating point values
Petr Savicky