Copyright | (c) Levent Erkok |
---|---|
License | BSD3 |
Maintainer | erkokl@gmail.com |
Stability | experimental |
Safe Haskell | Safe-Inferred |
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
Floating FP Source # | Floating instance for big-floats |
Defined in Data.SBV.Core.SizedFloats | |
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 # | |
Num FP Source # | Num instance for big-floats |
Fractional FP Source # | Fractional instance for big-floats |
Real FP Source # | Real instance for big-floats. Beware, not that well tested! |
Defined in Data.SBV.Core.SizedFloats toRational :: FP -> Rational # | |
RealFrac FP Source # | Real-frac instance for big-floats. Beware, not that well tested! |
Show FP Source # | |
Eq FP Source # | |
Ord 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.