chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] read / write floats


From: Thomas Christian Chust
Subject: Re: [Chicken-users] read / write floats
Date: Sun, 26 Aug 2007 16:39:18 +0200
User-agent: Thunderbird 2.0.0.6 (Macintosh/20070728)

Gábor Balázs wrote:

> [...]
> I don't see the benefit of this standard deviation of chicken scheme.
> If one says it is about performance, I can say scheme's text based
> read/write is far from the performance what binary I/O can provide.
> The real benefit of read/write is simplicity and portability.
> [...]

Hello,

the problem here is that CHICKEN uses standard C library routines to
print floating point numbers as decimal strings and using those it is
not possible to portably reproduce the full precision of every numbers
on every system. Whether the internal and textual external
representation of a floating point number are considered equal depends
on the number of digits printed, the precision of the processor's
floating point registers and the details of how the processor performs
rounding.

I think it is generally a bad idea to rely on equality checks for
floating point numbers in portable code. It is probably far better to
check whether the distance between the two number in question is small.

However, your problem may possibly be fixed by editing the file
runtime.c of the CHICKEN sources, increasing the value of the constant
FLONUM_PRINT_PRECISION (~16 digits for 64bit IEEE floating point systems
should be sufficient) and recompiling CHICKEN.

cu,
Thomas




reply via email to

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