[Haskell-cafe] 1/0

David Roundy daveroundy at gmail.com
Mon Jun 16 19:18:01 EDT 2008

On Mon, Jun 16, 2008 at 4:07 PM, Evan Laforge <qdunkan at gmail.com> wrote:
> 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.

There is a good reason for 1/0 being infinity, as it allows correct
programs to give correct answers even in the presence of underflow and

> 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.  Or something.  But then
> what about this note in Control.Exception:

That's just not true.  It depends on how your system (compiler?) is
configured, but the default on most systems that I've used is to
return NaNs.


More information about the Haskell-Cafe mailing list