[Haskell-cafe] Exception for NaN
daniel.is.fischer at googlemail.com
Fri May 13 01:50:55 CEST 2011
On Friday 13 May 2011 01:19:52, Ganesh Sittampalam wrote:
> On 12/05/2011 19:41, Nick Bowler wrote:
> > On 2011-05-12 21:14 +0400, Grigory Sarnitskiy wrote:
> >> I don't want NaN to propagate, it is merely stupid, it should be
> >> terminated.
> > NaN propagation is not stupid. Frequently, components of a
> > computation that end up being NaN turn out to be irrelevant at a
> > later point, in which case the NaNs can be discarded.
> Unfortunately, if a NaN reaches a comparison operation, it can lead to
> an end result that doesn't contain NaNs, but was still influenced by
Prelude Data.List> maximum [0,-1,0/0,-5,-6,-3,0/0,-2]
Prelude Data.List> minimum [0,-1,0/0,-5,-6,-3,0/0,-2]
Prelude Data.List> sort [0,-1,0/0,-5,-6,-3,0/0,-2]
As usual, when dealing with floating point numbers, you have to know what
you're doing. There are situations where the appearence of NaNs is
harmless, in others, they're poisonous.
More information about the Haskell-Cafe