|
From: | felix |
Subject: | Re: [Chicken-users] Odd floating-point representations |
Date: | Wed, 15 Oct 2003 17:31:07 +0200 |
User-agent: | Opera7.11/Linux M2 build 406 |
When I evaluate most flonums the result is as expected:0.390.39 But sometimes it isn't:(list 0.07 0.56 0.69 0.81 0.94)(0.07000000000000001 0.5600000000000001 0.6899999999999999 0.8100000000000001 0.9399999999999999) This is problematic in some situations. Can anyone explain what's going on here?
The C floating-point to string conversion routines used by the runtime system produce this when the precision is set too high. Currently it uses 16, so if you change the definition of FLONUM_PRINT_PRECISION in runtime.c from 16 to 15, you should get decent output (at least on Linux, where I've tested it). (Is it me, or is the whole number-to-string-and-back conversion stuff provided by the C runtime library kludgy hack?) cheers, felix
[Prev in Thread] | Current Thread | [Next in Thread] |