# Just Launched: You can now import projects and releases from Google Code onto SourceForge

We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps.

## [Ecls-list] Rounding bug in float

 [Ecls-list] Rounding bug in float From: Raymond Toy - 2009-03-25 04:41:56 ```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 ```

 [Ecls-list] Rounding bug in float From: Raymond Toy - 2009-03-25 04:41:56 ```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 ```
 Re: [Ecls-list] Rounding bug in float From: Juan Jose Garcia-Ripoll - 2009-03-25 09:07:43 ```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 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@... > 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 ```
 Re: [Ecls-list] Rounding bug in float From: Raymond Toy - 2009-03-26 02:12:15 ```Juan Jose Garcia-Ripoll wrote: > 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 > Bummer. A little googling for mpq_get_d says it's supposed to truncate, so I guess that explains the result you see. Too bad there doesn't seem to be a way to get round-to-nearest. Ray ```
 Re: [Ecls-list] Rounding bug in float From: Robert Dodier - 2009-03-30 17:52:58 ```On Tue, Mar 24, 2009 at 10:41 PM, Raymond Toy 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. I'm surprised the CLHS doesn't offer any guidance here. About FLOAT, it says only "If a prototype is supplied, a float is returned that is mathematically equal to number but has the same format as prototype." Nothing about what to do when there is no float which is mathematically equivalent to the argument. CLHS goes on to say "Exceptional Situations: None." so FLOAT must return a value .... FWIW Robert Dodier ```
 Re: [Ecls-list] Rounding bug in float From: Juan Jose Garcia-Ripoll - 2009-03-30 18:04:10 ```On Mon, Mar 30, 2009 at 7:52 PM, Robert Dodier wrote: > On Tue, Mar 24, 2009 at 10:41 PM, Raymond Toy 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. > > I'm surprised the CLHS doesn't offer any guidance here. One thing that may be causing this is that float epsilon is too small. The value of the floating point epsilon is computed with a program and it is well known that Intel processors provide more precision than it is mandated by floating point standards. GMP on the other hand, probably sticks to the 54 bits that a floating point number uses. One solution to this would be to use GMP's mpfr class and the extended functions mpfr_set_q and mpfr_get_d, which allow for arbitrary precision, but that is an overkill, isn't it? Juanjo -- Instituto de Física Fundamental, CSIC c/ Serrano, 113b, Madrid 28009 (Spain) http://juanjose.garciaripoll.googlepages.com ```
 Re: [Ecls-list] Rounding bug in float From: Robert Dodier - 2009-03-30 22:27:26 ```On Mon, Mar 30, 2009 at 12:03 PM, Juan Jose Garcia-Ripoll wrote: > One solution to this would be to use GMP's mpfr class and the extended > functions mpfr_set_q and mpfr_get_d, which allow for arbitrary > precision, but that is an overkill, isn't it? I guess so, but at this point I am still trying to figure out what (if anything) is mandated by the CL standard. Maybe ECL's behavior is conformant, maybe not, or maybe specification is ambiguous. best Robert Dodier ```