[Haskell-cafe] 1/0
Xiao-Yong Jin
xj2106 at columbia.edu
Mon Jun 16 19:35:24 EDT 2008
"Evan Laforge" <qdunkan at gmail.com> writes:
> So, I know this has been discussed before, but:
>
>> 1/0
> Infinity
>> 0/0
> NaN
>
> ... so I see from the archives that Infinity is mandated by ieee754
> even though my intuition says both should be NaN.
>
> Every other language throws an exception, even C will crash the
> program, so I'm guessing it's telling the processor / OS to turn these
> into signals, while GHC is turning that off. [...]
No, C will not, with floating point type. The following
program prints out a string "inf\n".
#include <stdio.h>
int main (void)
{
double a=1, b=0;
double i;
i = a / b;
printf ("%g\n",i);
return 0;
}
I believe Haskell is behaving rationally.
Cheers,
Xiao-Yong
--
c/* __o/*
<\ * (__
*/\ <
More information about the Haskell-Cafe
mailing list