Bill Schottstaedt | 1 Jul 16:32

big number printout

Not sure this is a bug, but it is confusing:

gosh> (gauche-version)
"0.8.13"
gosh> (+ 40816513889983671.0 3.0)
4.081651388998367e16
gosh> (= (+ 40816513889983671.0 3.0) 4.081651388998367e16)   
#t
gosh> (= (+ 40816513889983671.0 3.0) 40816513889983674.0)
#t
gosh> (= 40816513889983670.0 40816513889983674.0)
#t
gosh> (= 4.0816513889983670 4.0816513889983674) 
#f

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Shiro Kawai | 21 Jul 05:17

Re: big number printout

From: "Bill Schottstaedt" <bil <at> ccrma.Stanford.EDU>
Subject: [Gauche-devel] big number printout
Date: Tue, 1 Jul 2008 07:35:27 -0700

> Not sure this is a bug, but it is confusing:
> 
> gosh> (gauche-version)
> "0.8.13"
> gosh> (+ 40816513889983671.0 3.0)
> 4.081651388998367e16
> gosh> (= (+ 40816513889983671.0 3.0) 4.081651388998367e16)   
> #t
> gosh> (= (+ 40816513889983671.0 3.0) 40816513889983674.0)
> #t
> gosh> (= 40816513889983670.0 40816513889983674.0)
> #t
> gosh> (= 4.0816513889983670 4.0816513889983674) 
> #f

The confusing part the last one, right?
The first four examples merely show that the 10^0 digit
of 40816513889983671.0 falls out of the precision limit;
no wonder with the floating point numbers.

The last one might hit you strange, though.  Although the
16th digit of 4.0816513889983674e16 doesn't matter,
the 16th digit of 4.0816513889983674 does.

The minimum required digits in decimal to represent IEEE
double-precision floating point numbers accurately varies
(Continue reading)

Bill Schottstaedt | 21 Jul 13:18

Re: big number printout

Thanks very much for the explanation!  I should not send bug reports
at the end of a frustrating day -- the real problem started with a
different Scheme that actually had about 12 honest digits -- I
said "what does Gauche do?" and only got more tangled up.
Since every implementation is different, it would be nice to
know in advance the range for inexact integers -- I could
then add that check to my code.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

Gmane