Safe Haskell | Trustworthy |
---|---|
Language | Haskell2010 |
Computation with high-precision floats.
Synopsis
- data BigFloat
- bfPosZero :: BigFloat
- bfNegZero :: BigFloat
- bfPosInf :: BigFloat
- bfNegInf :: BigFloat
- bfNaN :: BigFloat
- bfFromWord :: Word64 -> BigFloat
- bfFromInt :: Int64 -> BigFloat
- bfFromDouble :: Double -> BigFloat
- bfFromInteger :: Integer -> BigFloat
- bfFromString :: Int -> BFOpts -> String -> (BigFloat, Status)
- bfToDouble :: RoundMode -> BigFloat -> (Double, Status)
- bfToString :: Int -> ShowFmt -> BigFloat -> String
- bfToRep :: BigFloat -> BFRep
- data BFRep
- data BFNum
- bfFromBits :: BFOpts -> Integer -> BigFloat
- bfToBits :: BFOpts -> BigFloat -> Integer
- bfIsFinite :: BigFloat -> Bool
- bfIsInf :: BigFloat -> Bool
- bfIsZero :: BigFloat -> Bool
- bfIsNaN :: BigFloat -> Bool
- bfIsNormal :: BFOpts -> BigFloat -> Bool
- bfIsSubnormal :: BFOpts -> BigFloat -> Bool
- bfCompare :: BigFloat -> BigFloat -> Ordering
- bfSign :: BigFloat -> Maybe Sign
- bfExponent :: BigFloat -> Maybe Int64
- bfIsPos :: BigFloat -> Bool
- bfIsNeg :: BigFloat -> Bool
- data Sign
- bfNeg :: BigFloat -> BigFloat
- bfAbs :: BigFloat -> BigFloat
- bfAdd :: BFOpts -> BigFloat -> BigFloat -> (BigFloat, Status)
- bfSub :: BFOpts -> BigFloat -> BigFloat -> (BigFloat, Status)
- bfMul :: BFOpts -> BigFloat -> BigFloat -> (BigFloat, Status)
- bfDiv :: BFOpts -> BigFloat -> BigFloat -> (BigFloat, Status)
- bfRem :: BFOpts -> BigFloat -> BigFloat -> (BigFloat, Status)
- bfFMA :: BFOpts -> BigFloat -> BigFloat -> BigFloat -> (BigFloat, Status)
- bfMulWord :: BFOpts -> BigFloat -> Word64 -> (BigFloat, Status)
- bfMulInt :: BFOpts -> BigFloat -> Int64 -> (BigFloat, Status)
- bfMul2Exp :: BFOpts -> BigFloat -> Int64 -> (BigFloat, Status)
- bfSqrt :: BFOpts -> BigFloat -> (BigFloat, Status)
- bfPow :: BFOpts -> BigFloat -> BigFloat -> (BigFloat, Status)
- bfRoundFloat :: BFOpts -> BigFloat -> (BigFloat, Status)
- bfRoundInt :: RoundMode -> BigFloat -> (BigFloat, Status)
- bfUnsafeThaw :: BigFloat -> BF
- bfUnsafeFreeze :: BF -> BigFloat
- module LibBF.Opts
Constants
Arbitrary precision floating point numbers.
Conversions
bfFromWord :: Word64 -> BigFloat Source #
A floating point number corresponding to the given word.
bfFromDouble :: Double -> BigFloat Source #
A floating point number corresponding to the given double.
bfFromInteger :: Integer -> BigFloat Source #
A floating point number corresponding to the given integer.
Parse a number from the given string. Returns @NaN` if the string does not correspond to a number we recognize.
Render as a String
, using the given settings.
An explicit representation for big nums.
Representations for unsigned floating point numbers.
Make a float using "raw" bits representing the bitvector representation of a floating-point value with the exponent and precision bits given by the options.
bfToBits :: BFOpts -> BigFloat -> Integer Source #
Turn a float into raw bits.
NaN
is represented as a positive "quiet" NaN
(most significant bit in the significand is set, the rest of it is 0).
Predicates
bfIsFinite :: BigFloat -> Bool Source #
Is this a finite (i.e., non-infinite, non NaN) number.
bfIsNormal :: BFOpts -> BigFloat -> Bool Source #
This is a "normal" number, which means it is not a NaN, not a zero, not infinite, and not subnormal.
bfIsSubnormal :: BFOpts -> BigFloat -> Bool Source #
This number is "subnormal", which means it is among the smallest representable numbers for the given precision and exponent bits. These numbers differ from "normal" numbers in that they do not use an implicit leading 1 bit in the binary representation.
bfCompare :: BigFloat -> BigFloat -> Ordering Source #
Compare the two numbers. The special values are ordered like this:
- -0 < 0
- NaN == NaN
- NaN is larger than all other numbers
Note that this differs from (<=)
bfSign :: BigFloat -> Maybe Sign Source #
Get the sign of a number. Returns Nothing
if the number is NaN
.
bfExponent :: BigFloat -> Maybe Int64 Source #
Get the exponent for the given number. Infinity, zero and NaN do not have an exponent.
Indicates if a number is positive or negative.
Arithmetic
bfAdd :: BFOpts -> BigFloat -> BigFloat -> (BigFloat, Status) Source #
Add two numbers useing the given options.
bfSub :: BFOpts -> BigFloat -> BigFloat -> (BigFloat, Status) Source #
Subtract two numbers useing the given options.
bfMul :: BFOpts -> BigFloat -> BigFloat -> (BigFloat, Status) Source #
Multiply two numbers using the given options.
bfDiv :: BFOpts -> BigFloat -> BigFloat -> (BigFloat, Status) Source #
Divide two numbers useing the given options.
bfRem :: BFOpts -> BigFloat -> BigFloat -> (BigFloat, Status) Source #
Compute the remainder x - y * n
where n
is the integer
nearest to x/y
(with ties broken to even values of n
).
bfFMA :: BFOpts -> BigFloat -> BigFloat -> BigFloat -> (BigFloat, Status) Source #
Compute the fused-multiply-add (x*y)+z
bfMulWord :: BFOpts -> BigFloat -> Word64 -> (BigFloat, Status) Source #
Multiply a number and a word, using the given options.
bfMulInt :: BFOpts -> BigFloat -> Int64 -> (BigFloat, Status) Source #
Multiply a number and an int, using the given options.
bfSqrt :: BFOpts -> BigFloat -> (BigFloat, Status) Source #
Square root of two numbers useing the given options.
bfPow :: BFOpts -> BigFloat -> BigFloat -> (BigFloat, Status) Source #
Exponentiate a word to a positive integer power.
Rounding
bfRoundFloat :: BFOpts -> BigFloat -> (BigFloat, Status) Source #
Round to a float matching the input parameters.
bfRoundInt :: RoundMode -> BigFloat -> (BigFloat, Status) Source #
Round to an integer using the given rounding mode.
Mutability
bfUnsafeThaw :: BigFloat -> BF Source #
Make a number mutable. WARNING: This does not copy the number, so it could break referential transperancy.
bfUnsafeFreeze :: BF -> BigFloat Source #
Make a number immutable. WARNING: This does not copy the number, so it could break referential transperancy.
Limits
Configuration
module LibBF.Opts