[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-hackers] CR: Division by inexact zero should return infinit
From: |
Alaric Snell-Pym |
Subject: |
Re: [Chicken-hackers] CR: Division by inexact zero should return infinity/nan |
Date: |
Thu, 25 Aug 2011 14:03:28 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 08/25/2011 11:07 AM, Felix wrote:
>> On Thu, Aug 25, 2011 at 03:50:40AM -0400, Felix wrote:
>>>> This is really annoying, as you'd get "random" errors when you're working
>>>> with numbers in the extreme ranges representable by flonums even if you
>>>> absolutely know you're dividing by nonzero values.
>>>
>>> Yes, that's floating point.
>>
>> No, that's the division operator in Chicken. The particular floating
>> point representation we are using explicitly supports returning infinities.
>
> It is the general problem of floating-point equality. The underlying
> floating point representation is a platform-specific detail. It
> happens to be IEEE in most cases. R5RS doesn't require IEEE. Chicken
> does not (at least to my knowledge) require IEEE.
Floating point equality is poorly defined; therefore, we should avoid it
where possible, and avoid baking its semantics into other parts of the
system. When dividing by a floating-point number, therefore, we need to
avoid the "conditional branch" of return a value / raise an error
depending on the results of a floating point comparison...
Dividing by an inexact zero to get an inexact infinity is much safer. If
you divide by a very small number you can easily get a near-infinite
number in FP anyway; going slightly smaller (to an inexact zero) would
then produce a correspondingly slightly larger (inexact infinity)
result, rather than a nasty surprise :-)
ABS
- --
Alaric Snell-Pym
http://www.snell-pym.org.uk/alaric/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk5WSCAACgkQRgz/WHNxCGrSPgCfVMxxAuWgLeiO6/N5+zcxWOwB
ROsAnRuMAj264QNZMKth4J134m+5ToAT
=XOPj
-----END PGP SIGNATURE-----
- [Chicken-hackers] CR: Division by inexact zero should return infinity/nan, Peter Bex, 2011/08/24
- Re: [Chicken-hackers] CR: Division by inexact zero should return infinity/nan, John Cowan, 2011/08/24
- Re: [Chicken-hackers] CR: Division by inexact zero should return infinity/nan, Felix, 2011/08/25
- Re: [Chicken-hackers] CR: Division by inexact zero should return infinity/nan, Peter Bex, 2011/08/25
- Re: [Chicken-hackers] CR: Division by inexact zero should return infinity/nan, Ivan Shmakov, 2011/08/25
- Re: [Chicken-hackers] CR: Division by inexact zero should return infinity/nan, Felix, 2011/08/25
- Re: [Chicken-hackers] CR: Division by inexact zero should return infinity/nan, Alex Shinn, 2011/08/25
- Re: [Chicken-hackers] CR: Division by inexact zero should return infinity/nan,
Alaric Snell-Pym <=
- Re: [Chicken-hackers] CR: Division by inexact zero should return infinity/nan, Felix, 2011/08/25
- Re: [Chicken-hackers] CR: Division by inexact zero should return infinity/nan, John Cowan, 2011/08/25
- Re: [Chicken-hackers] CR: Division by inexact zero should return infinity/nan, John Cowan, 2011/08/25