On 4/10/01 at 7:34 PM FrançoisVan Emelen wrote:
>Hi,
>
>Can someone explain this?
>
>100 CLS
>120 d=DATE(2001,6,11,0,0,0)
>140 PRINT d
>160 d1=1.2762214E9
>180 PRINT DATE$(d)
>200 PRINT DATE$(d1)
>
>d1 is the value returned by d (line 140)
>Why doesn't line 200 return the same date as line 180?
>...sometimes they aren't (and then the difference seems to be
>6m40s). Where have those 6m40s gone and why?
>
>Any idea?
The answer is actually quite obvious. 1.2762214E9 means that it is a whole
number with 9 digits after the decimal point, yet obviously only 7 are
printed. Precision is lost once the original value of d, which is a 32-bit
unsigned integer is alowed to print as a floating point number. This is
really a bug in print, not in the floating point representation itself,
which on the QL has a 32-bit mantissa. Because of this, if d is not alowed
to print (as in Tony's d=d1 example), all the bits are preserved, and you
will get the same when you do PRINT DATE$. You can try doing print hex$(d)
and print hex$(d1) in your program above and you'll see what I mean.
Nasta