Re: [Haskell-cafe] How odd...

Um... why would infinity * 0 be NaN? That doesn't make sense... Infinity times anything is Infinity. Zero times anything is zero. So what should Infinity * zero be? There isn't one right answer. In this case the "morally correct" answer is zero, but in other contexts it might be Infinity or even some finite number other than zero.
I don't follow. Infinity times any positive quantity gives positive infinity. Infinity times any negative quantity gives negative infinity. Infinity times zero gives zero. What's the problem?
Consider 0.0 / 0.0, which also evaluates to NaN.
Division by zero is *definitely* undefined. (The equation 0 * k = v has no solutions.)

Infinity is a very slippery concept, you can't compute with it like that.
You can compute various limits, though.
So, e.g., for a > 0
lim x*a -> Inf
x->Inf
and
lim x*0 -> 0
x->Inf
But
lim x*(1/x) -> 1
x->Inf
And that last one would be "Inf*0" in the limit. In fact, you can make
Inf*0 any number you like. So NaN is the sensible.
-- Lennart
On 8/4/07, Andrew Coppin
Um... why would infinity * 0 be NaN? That doesn't make sense... Infinity times anything is Infinity. Zero times anything is zero. So what should Infinity * zero be? There isn't one right answer. In this case the "morally correct" answer is zero, but in other contexts it might be Infinity or even some finite number other than zero.
I don't follow.
Infinity times any positive quantity gives positive infinity. Infinity times any negative quantity gives negative infinity. Infinity times zero gives zero.
What's the problem?
Consider 0.0 / 0.0, which also evaluates to NaN.
Division by zero is *definitely* undefined. (The equation 0 * k = v has no solutions.)
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 5 Aug 2007, at 5:26 am, Andrew Coppin wrote:
Infinity times any positive quantity gives positive infinity. Infinity times any negative quantity gives negative infinity. Infinity times zero gives zero.
What's the problem?
That in IEEE arithmetic, infinity times zero is *NOT* zero. Everything becomes clear if you think +0 = some non-standard real bigger than 0 but smaller than any standard positive real, a possibly different one every time -0 = some non-standard real smaller than 0 but bigger than any non-standard negative real, a possibly different one every time +oo = 1/(+0), remembering that this is a possibly different one each time -oo = 1/(-0) So +oo * +0 is (1/eps1) * eps2 = eps2/eps1 which could have *any* positive non-standard real value.
Consider 0.0 / 0.0, which also evaluates to NaN.
Division by zero is *definitely* undefined.
No, division by zero is perfectly well defined in IEEE arithmetic. If x is a strictly positive number then x/(+0) = +Infinity. If x is a strictly negative number then x/(+0) = -Infinity. positive/(-0) = (-positive)/(+0) = -Infinity. negative/(-0) = (-negative)/(+0) = +Infinity. Once again, everything becomes clear when you realise that IEEE arithmetic doesn't really represent 0 but instead has a pair of non-standard reals one on either side (except that you can never depend on exactly what the value is). So 1/(+0) is clearly 1/eps1 = some big non-standard real = +Infinity, but +0/+0 is eps1/eps2 and we don't know what that is. I know that the signed zero and infinities stuff is mathematically odd, but it's closely related to the ability to write floating point stuff without exception handling, so that if at the end you got NaN something went wrong (and you need to try another method), otherwise it didn't. The C99 standard (a draft of which is easy to find on the web) is perhaps the easiest place to find out what this means for functions other than the classical arithmetic operations. (Personally I've always thought that sqrt(-0) = -0 was more confusing than anyone needed, but I can see why they did it.)
participants (3)
-
Andrew Coppin
-
Lennart Augustsson
-
ok