[Haskell-cafe] Exception for NaN
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe