Error handling in calculations

L.S., When playing with exceptions, I noticed the following strangeness: *Main> 1 / 0 Infinity *Main> 1 `div` 0 *** Exception: divide by zero This is in GHCi 6.8.2; WinHugs Sep 2006 gives: Main> 1 / 0 1.#INF Main> 1 `div` 0 Program error: divide by zero Is this difference between fractional and integral calculation intentional? It makes error handling more difficult. -- Met vriendelijke groet, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ --

* hjgtuyl@chello.nl
L.S.,
When playing with exceptions, I noticed the following strangeness: *Main> 1 / 0 Infinity *Main> 1 `div` 0 *** Exception: divide by zero
This is in GHCi 6.8.2; WinHugs Sep 2006 gives: Main> 1 / 0 1.#INF Main> 1 `div` 0
Program error: divide by zero
Is this difference between fractional and integral calculation intentional? It makes error handling more difficult.
I think it's because in the first case you have floating-point overflow (which can happen not just in case of division by 0 and means some very-large number -- remember, you cannot distinguish 0 and 0.00..001) and in the second case it's just division by zero -- meaningless operation. -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock...
participants (2)
-
hjgtuyl@chello.nl
-
Roman Cheplyaka