gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] RE: GCL bugs (decode-float, rationalize, expt)


From: Stavros Macrakis
Subject: [Gcl-devel] RE: GCL bugs (decode-float, rationalize, expt)
Date: Fri, 3 Jan 2003 21:07:34 -0500

Camm--

Thanks for your answer.

> if you could detail what results you would expect to the
> commands below that differ from the present behavior.

OK, see below.  I hope this is helpful.

       -s

-----------------------------

> >(rationalize 1.0e-300)
> 
> 6032057205060441/603205720506044084884212454315773567705025225
> 17485057817966150649616223444937272933709735781382657437082254
> 25014400837164813540499979063179105919597766951022193355091707
> 89603485068403905907918039678834910609558429008744607641377146
> 89404772415506707531455176029312243924240295474299938241298892
> 35158145614364972941312

This is the correct value for (rational 1.0e-300).  However,
rationalize is supposed to take into account the precision of
floating-point representation to minimize the denominator, so
the correct value here would be 1/x, where x is some integer
near 10^300 (or possibly x/y, x>1, y<10^300).

> >(float (rationalize 1.0e-320))
> 0.0

Incorrect.  (rationalize 1.0e-320) should be 1/x, where x is
somewhere near 10^320, and (float (rationalize 1.0e-320) should be
1.0e-320.

> >(expt 10.0 -310)
> 0.0

Incorrect.  Should be 1.0e-310.

> >(expt 10 -300)
> 
> 1/100000000000000000000000000000000000000000000000000000000000
> 00000000000000000000000000000000000000000000000000000000000000
> 00000000000000000000000000000000000000000000000000000000000000
> 00000000000000000000000000000000000000000000000000000000000000
> 0000000000000000000000000000000000000000000000000000000

Correct.

> >(decode-float 1.0e-300)
> 0.66969287949141709
> -996
> 1.0

Correct.

> >(decode-float 1.0e-320)
> 0.50000000000022471
> -1022
> 1.0

Incorrect.  0.5 * 2^-1022 = 1.1e-308, not 1.0e-320.
Correct answer is roughly .49, -1062, 1.0

> >(integer-decode-float 1.0)
> 4503599627370496
> -52
> 1

Correct. 450xxxx = 2^52, so 450xxxx * 2^-52=1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]