-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A binding to the libBF library. -- -- LibBF is a C library for working with arbitray precision IEEE 754 -- floating point numbers. @package libBF @version 0.5.1 -- | Configuration and results for FP computation. module LibBF.Opts -- | Specifies various computation settings, combined with -- Semigroup. data BFOpts BFOpts :: !LimbT -> !FlagsT -> BFOpts -- | Allow denormalized answers. allowSubnormal :: BFOpts -- | Precision 11, exponent 5 float16 :: RoundMode -> BFOpts -- | Precision 24, exponent 8 float32 :: RoundMode -> BFOpts -- | Precision 53, exponent 11 float64 :: RoundMode -> BFOpts -- | Precision 113, exponent 15 float128 :: RoundMode -> BFOpts -- | Precision 237, exponent 19 float256 :: RoundMode -> BFOpts -- | Use this many bits to represent the mantissa in the computation. The -- input should be in the interval defined by precMin and -- precMax precBits :: Int -> BFOpts -- | The smallest supported precision (in bits). precBitsMin :: Int -- | The largest supported precision (in bits). Memory could run out before -- we run out of precision. precBitsMax :: Int -- | Use infinite precision. This should be used with caution, as it could -- exhause memory, and at the moment the library does not handle this -- gracefully at all (core dumps). infPrec :: BFOpts -- | Set how many bits to use to represent the exponent. Should fit in the -- range defined by expBitsMin and expBitsMax. expBits :: Int -> BFOpts -- | The smallest supported number of bits in the exponent. expBitsMin :: Int -- | The largest number of exponent bits supported. expBitsMax :: Int -- | Use the given rounding mode. If none is specified, then the default is -- NearEven. rnd :: RoundMode -> BFOpts -- | Specifies how to round when the result can't be precise. newtype RoundMode RoundMode :: FlagsT -> RoundMode -- | Round to nearest, ties go to even. pattern NearEven :: RoundMode -- | Round toward zero. pattern ToZero :: RoundMode -- | Round down (toward -inf). pattern ToNegInf :: RoundMode -- | Round up (toward +inf). pattern ToPosInf :: RoundMode -- | Round to nearest, ties go away from zero. pattern NearAway :: RoundMode -- | Round away from zero pattern Away :: RoundMode -- | Faithful rounding (nondeterministic, either ToPosInf or -- ToNegInf). The Inexact flag is always set. pattern Faithful :: RoundMode -- | Settings for rendering numbers as String. data ShowFmt ShowFmt :: !LimbT -> !FlagsT -> ShowFmt -- | Use this rounding mode. showRnd :: RoundMode -> ShowFmt -- | Show this many significant digits total . showFixed :: Word64 -> ShowFmt -- | Show this many digits after the decimal point. showFrac :: Word64 -> ShowFmt -- | Use as many digits as necessary to match the required precision -- rounding to nearest and the subnormal+exponent configuration of -- FlagsT. The result is meaningful only if the input is already -- rounded to the wanted precision. -- -- Infinite precision, indicated by giving Nothing for the -- precision is supported when the radix is a power of two. showFree :: Maybe Word64 -> ShowFmt -- | same as showFree but uses the minimum number of digits (takes -- more computation time). showFreeMin :: Maybe Word64 -> ShowFmt -- | add 0x prefix for base 16, 0o prefix for base 8 or 0b prefix for base -- 2 if non zero value addPrefix :: ShowFmt -- | Show in exponential form. forceExp :: ShowFmt -- | Maximum radix when rendering to a for bf_atof and -- bf_froa. radixMax :: Int -- | A set of flags indicating things that might go wrong. newtype Status Status :: CInt -> Status -- | Succeeds if everything is OK. pattern Ok :: Status -- | We tried to perform an invalid operation. pattern InvalidOp :: Status -- | We divided by zero. pattern DivideByZero :: Status -- | The result can't be represented because it is too large. pattern Overflow :: Status -- | The result can't be represented because it is too small. pattern Underflow :: Status -- | The result is not exact. pattern Inexact :: Status -- | Memory error. NaN is returned. pattern MemError :: Status -- | Internal: type for limbs type LimbT = Word64 -- | Internal: type for signed limbs type SLimbT = Int64 -- | Internal: type for flags type FlagsT = Word32 instance GHC.Classes.Ord LibBF.Opts.Status instance GHC.Classes.Eq LibBF.Opts.Status instance GHC.Show.Show LibBF.Opts.RoundMode instance GHC.Show.Show LibBF.Opts.Status instance GHC.Base.Semigroup LibBF.Opts.ShowFmt instance GHC.Base.Semigroup LibBF.Opts.BFOpts -- | Mutable big-float computation. module LibBF.Mutable -- | Allocate a new numeric context. newContext :: IO BFContext -- | State of the current computation context. data BFContext -- | Allocate a new number. Starts off as zero. new :: BFContext -> IO BF -- | A mutable high precision floating point number. data BF -- | Assign NaN to the number. setNaN :: BF -> IO () -- | Assign a zero to the number. setZero :: Sign -> BF -> IO () -- | Assign an infinty to the number. setInf :: Sign -> BF -> IO () -- | Indicates if a number is positive or negative. data Sign -- | Negative Neg :: Sign -- | Positive Pos :: Sign -- | Assign from a word setWord :: Word64 -> BF -> IO () -- | Assign from an int setInt :: Int64 -> BF -> IO () -- | Assign from a double setDouble :: Double -> BF -> IO () -- | Set an integer. If the integer is larger than the primitive types, -- this does repreated Int64 additions and multiplications. setInteger :: Integer -> BF -> IO () -- | Assign from another number. setBF :: BF -> BF -> IO () -- | Set the value to the float parsed out of the given string. * The radix -- should not exceed maxRadix. * Sets the number to NaN -- on failure. * Assumes that characters are encoded with a single byte -- each. * Retruns: - Status for the conversion - How many bytes we -- consumed - Did we consume the whole input setString :: Int -> BFOpts -> String -> BF -> IO (Status, Int, Bool) -- | Check if the two numbers are equal. cmpEq :: BF -> BF -> IO Bool -- | Check if the first number is strictly less than the second. cmpLT :: BF -> BF -> IO Bool -- | Check if the first number is less than, or equal to, the second. cmpLEQ :: BF -> BF -> IO Bool -- | Compare the absolute values of the two numbers. See also cmp. cmpAbs :: BF -> BF -> IO Ordering -- | Compare the two numbers. The special values are ordered like this: -- --
-- x * 2 ^ y --Num :: Integer -> !Int64 -> BFNum -- | infinity Inf :: BFNum -- | Chunk a non-negative integer into words, least significatn first toChunks :: Integer -> [LimbT] instance GHC.Show.Show LibBF.Mutable.BFRep instance GHC.Classes.Ord LibBF.Mutable.BFRep instance GHC.Classes.Eq LibBF.Mutable.BFRep instance GHC.Show.Show LibBF.Mutable.BFNum instance GHC.Classes.Ord LibBF.Mutable.BFNum instance GHC.Classes.Eq LibBF.Mutable.BFNum instance GHC.Show.Show LibBF.Mutable.Sign instance GHC.Classes.Ord LibBF.Mutable.Sign instance GHC.Classes.Eq LibBF.Mutable.Sign -- | Computation with high-precision floats. module LibBF -- | Arbitrary precision floating point numbers. data BigFloat -- | Positive zero. bfPosZero :: BigFloat -- | Negative zero. bfNegZero :: BigFloat -- | Positive infinity. bfPosInf :: BigFloat -- | Negative infinity. bfNegInf :: BigFloat -- | Not-a-number. bfNaN :: BigFloat -- | A floating point number corresponding to the given word. bfFromWord :: Word64 -> BigFloat -- | A floating point number corresponding to the given int. bfFromInt :: Int64 -> BigFloat -- | A floating point number corresponding to the given double. bfFromDouble :: Double -> BigFloat -- | A floating point number corresponding to the given integer. bfFromInteger :: Integer -> BigFloat -- | Parse a number from the given string. Returns @NaN` if the string does -- not correspond to a number we recognize. bfFromString :: Int -> BFOpts -> String -> (BigFloat, Status) -- | Constant to a Double bfToDouble :: RoundMode -> BigFloat -> (Double, Status) -- | Render as a String, using the given settings. bfToString :: Int -> ShowFmt -> BigFloat -> String -- | The float as an exponentiated Integer. bfToRep :: BigFloat -> BFRep -- | An explicit representation for big nums. data BFRep -- | A signed number BFRep :: !Sign -> !BFNum -> BFRep -- | Not a number BFNaN :: BFRep -- | Representations for unsign floating point numbers. data BFNum -- | zero Zero :: BFNum -- |
-- x * 2 ^ y --Num :: Integer -> !Int64 -> BFNum -- | infinity Inf :: BFNum -- | Is this a "normal" (i.e., non-infinite, non NaN) number. bfIsFinite :: BigFloat -> Bool -- | Is this value a zero. bfIsZero :: BigFloat -> Bool -- | Is this value NaN. bfIsNaN :: BigFloat -> Bool -- | Compare the two numbers. The special values are ordered like this: -- --