Copyright | (c) Levent Erkok |
---|---|
License | BSD3 |
Maintainer | erkokl@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
A collection of arbitrary float operations.
Synopsis
- data FP = FP {}
- fpFromRawRep :: Bool -> (Integer, Int) -> (Integer, Int) -> FP
- fpFromBigFloat :: Int -> Int -> BigFloat -> FP
- fpNaN :: Int -> Int -> FP
- fpInf :: Bool -> Int -> Int -> FP
- fpZero :: Bool -> Int -> Int -> FP
- fpFromInteger :: Int -> Int -> Integer -> FP
- fpFromRational :: Int -> Int -> Rational -> FP
- fpFromFloat :: Int -> Int -> Float -> FP
- fpFromDouble :: Int -> Int -> Double -> FP
- fpEncodeFloat :: Int -> Int -> Integer -> Int -> FP
Type-sized floats
Internal representation of a parameterized float.
A note on cardinality: If we have eb exponent bits, and sb significand bits, then the total number of floats is 2^sb*(2^eb-1) + 3: All exponents except 11..11 is allowed. So we get, 2^eb-1, different combinations, each with a sign, giving us 2^sb*(2^eb-1) totals. Then we have two infinities, and one NaN, adding 3 more.
FP | |
|
Instances
Eq FP Source # | |
Floating FP Source # | Floating instance for big-floats |
Defined in Data.SBV.Core.SizedFloats | |
Fractional FP Source # | Fractional instance for big-floats |
Num FP Source # | Num instance for big-floats |
Ord FP Source # | |
Real FP Source # | Real instance for big-floats. Beware, not that well tested! |
Defined in Data.SBV.Core.SizedFloats toRational :: FP -> Rational # | |
RealFloat FP Source # | Real-float instance for big-floats. Beware! Some of these aren't really all that well tested. |
Defined in Data.SBV.Core.SizedFloats floatRadix :: FP -> Integer # floatDigits :: FP -> Int # floatRange :: FP -> (Int, Int) # decodeFloat :: FP -> (Integer, Int) # encodeFloat :: Integer -> Int -> FP # significand :: FP -> FP # scaleFloat :: Int -> FP -> FP # isInfinite :: FP -> Bool # isDenormalized :: FP -> Bool # isNegativeZero :: FP -> Bool # | |
RealFrac FP Source # | Real-frac instance for big-floats. Beware, not that well tested! |
Show FP Source # | |
Constructing values
fpFromRawRep :: Bool -> (Integer, Int) -> (Integer, Int) -> FP Source #
Convert from an signexponentmantissa representation to a float. The values are the integers representing the bit-patterns of these values, i.e., the raw representation. We assume that these integers fit into the ranges given, i.e., no overflow checking is done here.
fpNaN :: Int -> Int -> FP Source #
Make NaN. Exponent is all 1s. Significand is non-zero. The sign is irrelevant.
Operations
fpFromRational :: Int -> Int -> Rational -> FP Source #
Make a generalized floating-point value from a Rational
.
fpEncodeFloat :: Int -> Int -> Integer -> Int -> FP Source #
Encode from exponent/mantissa form to a float representation. Corresponds to encodeFloat
in Haskell.