Copyright | (C) 2015 Anselm Jonas Scholl |
---|---|
License | BSD3 |
Maintainer | Anselm Jonas Scholl <anselm.scholl@tu-harburg.de> |
Stability | experimental |
Portability | GHC-specific |
Safe Haskell | None |
Language | Haskell2010 |
Data.Bits.Floating
Description
Conversions between floating point values and integral values preserving the bit-patterns.
- class (Floating f, Integral w) => FloatingBits f w | f -> w where
- coerceToWord :: f -> w
- coerceToFloat :: w -> f
- nextUp :: f -> f
- nextDown :: f -> f
- ulp :: f -> f
- class ShowFloat f where
- showsFloat :: f -> ShowS
- showFloat :: f -> String
- fromCFloat :: CFloat -> Float
- fromCDouble :: CDouble -> Double
Bitwise operations
class (Floating f, Integral w) => FloatingBits f w | f -> w where Source
Methods
coerceToWord :: f -> w Source
Coerce a floating point number to an integral number preserving the bitwise representation.
coerceToFloat :: w -> f Source
Coerce a integral number to an floating point number preserving the bitwise representation.
Note: It is not always possible to do this. In particular, if we coerce
the bit pattern of a NaN value, we might get a NaN value with a different
bit pattern than we wanted, so it is possible that
.coerceToWord
(coerceToFloat
w) /= w
Return the next floating point value in the direction of +INF. If the argument is NaN, NaN is returned. If the argument is +INF, +INF is returned. If the argument is 0.0, the minimum value greater than 0.0 is returned.
Return the next floating point value in the direction of -INF. If the argument is NaN, NaN is returned. If the argument is -INF, +INF is returned. If the argument is 0.0, the minimum value smaller than 0.0 is returned.
Printing
class ShowFloat f where Source
Minimal complete definition