[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: |
Felix |
Subject: |
Re: [Chicken-hackers] CR: Division by inexact zero should return infinity/nan |
Date: |
Thu, 25 Aug 2011 06:07:25 -0400 (EDT) |
> 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.
>
>> > All other Schemes I tested with (Guile, Gauche, Scheme48, Racket and
>> > Gambit)
>> > return +inf.0 for (/ 1.0 0.0) and -inf.0 for (/ -1.0 0.0).
>> > They return +nan.0 for (/ 0.0 0.0). Extra data points would be welcome.
>>
>> CL signals div-by-zero.
>
> But we're a Scheme. Also, CL is overengineered design by committee
> and hence is and not tied to the IEEE standard (it's optional).
> According to the Hyperspec, this is actually not even defined; it says
> an implementation *might* raise an error on zero. Returning inf or nan
> is allowed too. I guess your favorite implementation just doesn't.
I haven't tried many, I'm afraid, but I think most do detect
div-by-zero. CL might be an big, hairy, archaic and overengineered
ball of crap, but R5RS (and later?) actually "recognizes the excellent
work of the Common Lisp committee and accepts many of their
recommendations." (6.2)
>
> We are, since we compile to C, which (AFAIK) is explicitly tied to IEEE
> floating point representation and semantics. At least, it is on modern
> machines. We're already using it everywhere (except in the division case)
I doubt C is tied to IEEE. It's the hardware that is.
cheers,
felix
- [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 <=
- 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, 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, John Cowan, 2011/08/25
- Re: [Chicken-hackers] CR: Division by inexact zero should return infinity/nan, John Cowan, 2011/08/25