[Haskell-cafe] 1/0

John Meacham john at repetae.net
Mon Jun 16 19:28:26 EDT 2008


On Mon, Jun 16, 2008 at 04:07:33PM -0700, Evan Laforge wrote:
> So, I know this has been discussed before, but:
> 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:

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.

        John


-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Haskell-Cafe mailing list