[Haskell-cafe] 1/0

Evan Laforge qdunkan at gmail.com
Mon Jun 16 19:41:23 EDT 2008

> No, The issue is that '/' is always floating point division in haskell,
> for integer division, use `div`.
> 1 `div` 0 throws an exception like you expect.
> GHC behaves exactly the same as C here. But in C whether '/' means
> floating point or integral division depends on the types of its
> arguments, in haskell they are separate operators.

Aha, I was missing something.  Indeed, 1.0/0.0 gives me infinity with
C.  Thanks for the clarification.  Python does throw for 1.0/0.0, but
I think there's a (not very commonly used) module to turn that off.
It might be nice for GHC to have a some way to turn exceptions on, but
I can accept getting NaNs, and doing the ieee754 thing by default
seems entirely reasonable.

But what about that NaN->Integer conversion thing?

More information about the Haskell-Cafe mailing list