[Haskell-cafe] Exception for NaN

Sterling Clover s.clover at gmail.com
Sat May 14 03:42:22 CEST 2011

You can set and clear float exception flags directly with ieee-utils: http://hackage.haskell.org/packages/archive/ieee-utils/0.4.0/doc/html/Numeric-IEEE-FloatExceptions.html

It looks like it needs a few tweaks to build with GHC 7, but even then that particularly module should still build fine.

So before a complicated numeric calculation, clear the flags. Then, after forcing the result, check to see if any flags have been triggered and take appropriate action. This is more efficient than checking the flags after every operation anyway.


On May 12, 2011, at 1:14 PM, Grigory Sarnitskiy wrote:

> How do I make my program stop whenever it gets somewhere NaN as a result during a calculation? If there is no appropriate flag for ghc maybe there exist flags for C to use in optc.
> I don't want NaN to propagate, it is merely stupid, it should be terminated.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110513/9c872f97/attachment.htm>

More information about the Haskell-Cafe mailing list