[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] bug and potential fix for numbers egg
From: |
Alex Shinn |
Subject: |
Re: [Chicken-users] bug and potential fix for numbers egg |
Date: |
Sat, 29 Mar 2008 12:57:21 +0900 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (darwin) |
>>>>> "John" == John Cowan <address@hidden> writes:
John> Alex Shinn scripsit:
>> As a potential workaround, I've attached a patch
>> which first checks if both the numerator and
>> denominator fit within a long (there's no direct way
>> to check if they fit in a double), and if so just
>> uses the straight C operations
>>
>> (double) numerator / (double) denominator
>>
>> which is more accurate than what GMP does!
John> I think that's the right general idea, but "long"
John> can be 32 bits, and often is; I think you need to
John> use a system-dependent type that can be guaranteed
John> to be 64 bits (does Chicken have one?).
Well, we're restricted to the GMP API, which gives us
mpz_fits_slong_p and mpz_get_d but no mpz_fits_double_p or
mpz_fits_long_long_p. So I believe this is the most
accurate we can hope for in a straightforward manner.
--
Alex