Copyright | (c) Levent Erkok |
---|---|
License | BSD3 |
Maintainer | erkokl@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
A library for formatting/analyzing FP and Integer values
- data FP = FP {}
- data Precision
- data IPrecision
- data Kind
- floatToFP :: Float -> FP
- doubleToFP :: Double -> FP
- stringToFP :: Precision -> String -> FP
- integerToFP :: Precision -> Integer -> FP
- displayFP :: FP -> String
- displayWord :: IPrecision -> Integer -> String
Internal representation of a Floating-point numbers
Complete internal representation for a floating-point number
FP | |
|
Floating point precision
data IPrecision Source #
Integer/Word precision
W8 | 8-bit unsigned (byte) |
I8 | 8-bit signed |
W16 | 16-bit unsigned (word) |
I16 | 16-bit signed |
W32 | 32-bit unsigned (double-word) |
I32 | 32-bit signed |
W64 | 64-bit unsigned (quad-word) |
I64 | 64-bit signed |
Eq IPrecision Source # | |
Show IPrecision Source # | Show instance for integer-precisions |
Kinds of floating point values
Creating FP values
doubleToFP :: Double -> FP Source #
Turn a Haskell double to the internal detailed FP representation
stringToFP :: Precision -> String -> FP Source #
Convert the given string to a IEEE number with the required precision
integerToFP :: Precision -> Integer -> FP Source #
Crack a Haskell Integer value as the given precision floating value. The Integer should be the value corresponding to the bit-pattern as the float is laid out in memory according to the IEEE rules.
Displaying FP and Int/Word values
displayFP :: FP -> String Source #
Display a Floating-point number in a nicely formatted way. (This function is also available
through the Show
instance for FP
, but is provided here for symmetry with displayWord
.)
displayWord :: IPrecision -> Integer -> String Source #
Display a Integer (signed/unsigned) number in a nicely formatted way