[Haskell-cafe] Re: FFI to double constants, printf
wren ng thornton
wren at freegeek.org
Thu Jul 23 21:11:33 EDT 2009
Brandon S. Allbery KF8NH wrote:
> On Jul 17, 2009, at 22:27 , Maurí cio wrote:
>> Is there maybe some way to check if a double or
>> long double do have a "proper" value?
>
>
> isNaN :: a -> Bool
> True if the argument is an IEEE "not-a-number" (NaN) value
>
> isInfinite :: a -> Bool
> True if the argument is an IEEE infinity or negative infinity
>
> isDenormalized :: a -> Bool
> True if the argument is too small to be represented in normalized format
>
> isNegativeZero :: a -> Bool
> True if the argument is an IEEE negative zero
>
> isIEEE :: a -> Bool
> True if the argument is an IEEE floating point number
>
> (in Prelude, even. Class RealFloat)
But don't trust the Prelude in Hugs (Sept2006)! The isInfinite and isNaN
methods are hard-coded to answer False, ignoring the argument entirely.
The logfloat package has the module Hugs.RealFloat[1] which provides
correct versions (defaulting to the Prelude definitions for non-Hugs
compilers).
[1]
http://hackage.haskell.org/packages/archive/logfloat/0.12.0.1/doc/html/Hugs-RealFloat.html
--
Live well,
~wren
More information about the Haskell-Cafe
mailing list