[Ecls-list] Rounding bug in float

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Wed Mar 25 09:07:32 UTC 2009


We rely on the GMP library for bignums and rational operations. It
seems not to be as precised as you would wish

> (setq a (/ (1- (ash 1 100)) (ash 1 100)))
1267650600228229401496703205375/1267650600228229401496703205376
> (float a 1.0d0)

Breakpoint 9, cl_float (narg=2, x=0x3491f0) at num_co.d:64
ecl_to_double (x=0x3491f0) at number.c:683
(gdb) call (double)__gmpq_get_d(aux)
$1 = 0.99999999999999989


On Wed, Mar 25, 2009 at 5:41 AM, Raymond Toy <toy.raymond at gmail.com> wrote:
> With ecl 8.12.0 on Linux, I get
>
> (float (/ (1- (ash 1 100)) (ash 1 100)) 1d0) -> .999999...99d0
>
> I think the answer should be 1d0 since the difference between 1 and the
> rational above is far less than double-float-negative-epsilon.  Both
> clisp and cmucl produce 1d0.
>
> Ray
>
>
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> _______________________________________________
> Ecls-list mailing list
> Ecls-list at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ecls-list
>



-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28009 (Spain)
http://juanjose.garciaripoll.googlepages.com




More information about the ecl-devel mailing list