gcl-devel
[Top][All Lists]
Advanced

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

[Gcl-devel] Re: GCL: format inaccurate on floats


From: Camm Maguire
Subject: [Gcl-devel] Re: GCL: format inaccurate on floats
Date: 12 Jan 2003 20:58:57 -0500

Greetings!  OK this should be cleared up now.  Thanks for your report! 

"Stavros Macrakis" <address@hidden> writes:

> In GCL 2.3.6
> prin1 and format/E/F give different results for floats.  Moreover,
> format/E/F is not reversible (that is, read of print of x isn't equal to
> x) -- several distinct floats give the same printed form.  I came across
> this while testing rationalize....
> 
> I couldn't test this is 2.5.0, because (expt 2 52) core dumps.
> 
> (do* ((i 0 (1+ i)))
>     ((> i 20))
>   (setq test (* (+ i (expt 2 52)) (expt 2.0 -52)))
>   (format t "~5d ~20S ~10,3G ~22,16F  ~22,16E
> " i test (- test 1) test test))
> 
>       prin1                 x-1           format/F             format/E
>     0 1.0                    0.00         1.0000000000000000
> 1.0000000000000000E+0 x
>     1 1.0000000000000002    2.220E-16     1.0000000000000000
> 1.0000000000000000E+0 x
>     2 1.0000000000000004    4.441E-16     1.0000000000000000
> 1.0000000000000000E+0 x
>     3 1.0000000000000007    6.661E-16     1.0000000000000010
> 1.0000000000000010E+0
>     4 1.0000000000000009    8.882E-16     1.0000000000000010
> 1.0000000000000010E+0
>     5 1.0000000000000011    1.110E-15     1.0000000000000010
> 1.0000000000000010E+0
>     6 1.0000000000000013    1.332E-15     1.0000000000000010
> 1.0000000000000010E+0
>     7 1.0000000000000016    1.554E-15     1.0000000000000020
> 1.0000000000000020E+0 x
>     8 1.0000000000000018    1.776E-15     1.0000000000000020
> 1.0000000000000020E+0 x
>     9 1.000000000000002     1.998E-15     1.0000000000000020
> 1.0000000000000020E+0 x
>    10 1.0000000000000022    2.220E-15     1.0000000000000020
> 1.0000000000000020E+0 x
>    11 1.0000000000000024    2.442E-15     1.0000000000000020
> 1.0000000000000020E+0 x
>    12 1.0000000000000027    2.665E-15     1.0000000000000030
> 1.0000000000000030E+0
>    13 1.0000000000000029    2.887E-15     1.0000000000000030
> 1.0000000000000030E+0
>    14 1.0000000000000031    3.109E-15     1.0000000000000030
> 1.0000000000000030E+0
>    15 1.0000000000000033    3.331E-15     1.0000000000000030
> 1.0000000000000030E+0
>    16 1.0000000000000036    3.553E-15     1.0000000000000040
> 1.0000000000000040E+0 x
>    17 1.0000000000000038    3.775E-15     1.0000000000000040
> 1.0000000000000040E+0 x
>    18 1.000000000000004     3.997E-15     1.0000000000000040
> 1.0000000000000040E+0 x
>    19 1.0000000000000042    4.219E-15     1.0000000000000040
> 1.0000000000000040E+0 x
>    20 1.0000000000000044    4.441E-15     1.0000000000000040
> 1.0000000000000040E+0 x
> 
> Asking for more digits in format just gives more zeroes.
> 
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

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