Safe Haskell | None |
---|---|
Language | Haskell2010 |
Mutable big-float computation.
Synopsis
- newContext :: IO BFContext
- data BFContext
- new :: BFContext -> IO BF
- data BF
- setNaN :: BF -> IO ()
- setZero :: Sign -> BF -> IO ()
- setInf :: Sign -> BF -> IO ()
- data Sign
- setWord :: Word64 -> BF -> IO ()
- setInt :: Int64 -> BF -> IO ()
- setDouble :: Double -> BF -> IO ()
- setInteger :: Integer -> BF -> IO ()
- setBF :: BF -> BF -> IO ()
- setString :: Int -> BFOpts -> String -> BF -> IO (Status, Int, Bool)
- cmpEq :: BF -> BF -> IO Bool
- cmpLT :: BF -> BF -> IO Bool
- cmpLEQ :: BF -> BF -> IO Bool
- cmpAbs :: BF -> BF -> IO Ordering
- cmp :: BF -> BF -> IO Ordering
- getSign :: BF -> IO (Maybe Sign)
- getExp :: BF -> IO (Maybe Int64)
- isFinite :: BF -> IO Bool
- isNaN :: BF -> IO Bool
- isZero :: BF -> IO Bool
- fneg :: BF -> IO ()
- fadd :: BFOpts -> BF -> BF -> BF -> IO Status
- faddInt :: BFOpts -> BF -> Int64 -> BF -> IO Status
- fsub :: BFOpts -> BF -> BF -> BF -> IO Status
- fmul :: BFOpts -> BF -> BF -> BF -> IO Status
- fmulInt :: BFOpts -> BF -> Int64 -> BF -> IO Status
- fmulWord :: BFOpts -> BF -> Word64 -> BF -> IO Status
- fmul2Exp :: BFOpts -> Int64 -> BF -> IO Status
- fdiv :: BFOpts -> BF -> BF -> BF -> IO Status
- fsqrt :: BFOpts -> BF -> BF -> IO Status
- fpow :: BFOpts -> BF -> BF -> BF -> IO Status
- fround :: BFOpts -> BF -> IO Status
- frint :: BFOpts -> BF -> IO Status
- toDouble :: RoundMode -> BF -> IO (Double, Status)
- toString :: Int -> ShowFmt -> BF -> IO String
- toRep :: BF -> IO BFRep
- data BFRep
- data BFNum
- module LibBF.Opts
- toChunks :: Integer -> [LimbT]
Allocation
newContext :: IO BFContext Source #
Allocate a new numeric context.
Assignment
Indicates if a number is positive or negative.
setInteger :: Integer -> BF -> IO () Source #
Set an integer. If the integer is larger than the primitive types, this does repreated Int64 additions and multiplications.
setString :: Int -> BFOpts -> String -> BF -> IO (Status, Int, Bool) Source #
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
Queries and Comparisons
cmpLEQ :: BF -> BF -> IO Bool Source #
Check if the first number is less than, or equal to, the second.
cmpAbs :: BF -> BF -> IO Ordering Source #
Compare the absolute values of the two numbers. See also cmp
.
cmp :: BF -> BF -> IO Ordering Source #
Compare the two numbers. The special values are ordered like this:
- -0 < 0
- NaN == NaN
- NaN is larger than all other numbers
getExp :: BF -> IO (Maybe Int64) Source #
Get the exponent of the number.
Returns Nothing
for inifinity, zero and NaN.
Arithmetic
fadd :: BFOpts -> BF -> BF -> BF -> IO Status Source #
Add two numbers, using the given settings, and store the result in the last.
faddInt :: BFOpts -> BF -> Int64 -> BF -> IO Status Source #
Add a number and an int64 and store the result in the last.
fsub :: BFOpts -> BF -> BF -> BF -> IO Status Source #
Subtract two numbers, using the given settings, and store the result in the last.
fmul :: BFOpts -> BF -> BF -> BF -> IO Status Source #
Multiply two numbers, using the given settings, and store the result in the last.
fmulInt :: BFOpts -> BF -> Int64 -> BF -> IO Status Source #
Multiply the number by the given int, and store the result in the second number.
fmulWord :: BFOpts -> BF -> Word64 -> BF -> IO Status Source #
Multiply the number by the given word, and store the result in the second number.
fdiv :: BFOpts -> BF -> BF -> BF -> IO Status Source #
Divide two numbers, using the given settings, and store the result in the last.
fsqrt :: BFOpts -> BF -> BF -> IO Status Source #
Compute the square root of the first number and store the result in the second.
fpow :: BFOpts -> BF -> BF -> BF -> IO Status Source #
Exponentiate the first number by the second, and store the result in the third number.
fround :: BFOpts -> BF -> IO Status Source #
Round to the nearest float matching the configuration parameters.
Convert from a number
toString :: Int -> ShowFmt -> BF -> IO String Source #
Render a big-float as a Haskell string.
The radix should not exceed maxRadix
.
An explicit representation for big nums.
Representations for unsign floating point numbers.
Configuration
module LibBF.Opts