libBF-0.5.1: A binding to the libBF library.

Safe HaskellTrustworthy
LanguageHaskell2010

LibBF

Contents

Description

Computation with high-precision floats.

Synopsis

Constants

data BigFloat Source #

Arbitrary precision floating point numbers.

Instances
Eq BigFloat Source #

IEEE 754 equality

Instance details

Defined in LibBF

Ord BigFloat Source #

IEEE 754 comparisons

Instance details

Defined in LibBF

Show BigFloat Source # 
Instance details

Defined in LibBF

NFData BigFloat Source # 
Instance details

Defined in LibBF

Methods

rnf :: BigFloat -> () #

bfPosZero :: BigFloat Source #

Positive zero.

bfNegZero :: BigFloat Source #

Negative zero.

bfPosInf :: BigFloat Source #

Positive infinity.

bfNegInf :: BigFloat Source #

Negative infinity.

bfNaN :: BigFloat Source #

Not-a-number.

Conversions

bfFromWord :: Word64 -> BigFloat Source #

A floating point number corresponding to the given word.

bfFromInt :: Int64 -> BigFloat Source #

A floating point number corresponding to the given int.

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.

bfFromString Source #

Arguments

:: Int

Base

-> BFOpts 
-> String 
-> (BigFloat, Status) 

Parse a number from the given string. Returns @NaN` if the string does not correspond to a number we recognize.

bfToString Source #

Arguments

:: Int

Base

-> ShowFmt 
-> BigFloat 
-> String 

Render as a String, using the given settings.

bfToRep :: BigFloat -> BFRep Source #

The float as an exponentiated Integer.

data BFRep Source #

An explicit representation for big nums.

Constructors

BFRep !Sign !BFNum

A signed number

BFNaN

Not a number

Instances
Eq BFRep Source # 
Instance details

Defined in LibBF.Mutable

Methods

(==) :: BFRep -> BFRep -> Bool #

(/=) :: BFRep -> BFRep -> Bool #

Ord BFRep Source # 
Instance details

Defined in LibBF.Mutable

Methods

compare :: BFRep -> BFRep -> Ordering #

(<) :: BFRep -> BFRep -> Bool #

(<=) :: BFRep -> BFRep -> Bool #

(>) :: BFRep -> BFRep -> Bool #

(>=) :: BFRep -> BFRep -> Bool #

max :: BFRep -> BFRep -> BFRep #

min :: BFRep -> BFRep -> BFRep #

Show BFRep Source # 
Instance details

Defined in LibBF.Mutable

Methods

showsPrec :: Int -> BFRep -> ShowS #

show :: BFRep -> String #

showList :: [BFRep] -> ShowS #

data BFNum Source #

Representations for unsign floating point numbers.

Constructors

Zero

zero

Num Integer !Int64
x * 2 ^ y
Inf

infinity

Instances
Eq BFNum Source # 
Instance details

Defined in LibBF.Mutable

Methods

(==) :: BFNum -> BFNum -> Bool #

(/=) :: BFNum -> BFNum -> Bool #

Ord BFNum Source # 
Instance details

Defined in LibBF.Mutable

Methods

compare :: BFNum -> BFNum -> Ordering #

(<) :: BFNum -> BFNum -> Bool #

(<=) :: BFNum -> BFNum -> Bool #

(>) :: BFNum -> BFNum -> Bool #

(>=) :: BFNum -> BFNum -> Bool #

max :: BFNum -> BFNum -> BFNum #

min :: BFNum -> BFNum -> BFNum #

Show BFNum Source # 
Instance details

Defined in LibBF.Mutable

Methods

showsPrec :: Int -> BFNum -> ShowS #

show :: BFNum -> String #

showList :: [BFNum] -> ShowS #

Predicates

bfIsFinite :: BigFloat -> Bool Source #

Is this a "normal" (i.e., non-infinite, non NaN) number.

bfIsZero :: BigFloat -> Bool Source #

Is this value a zero.

bfIsNaN :: BigFloat -> Bool Source #

Is this value NaN.

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. Assumes the input is not NaN.

bfExponent :: BigFloat -> Maybe Int64 Source #

Get the exponent for the given number. Infinity, zero and NaN do not have an exponent.

data Sign Source #

Indicates if a number is positive or negative.

Constructors

Neg

Negative

Pos

Positive

Instances
Eq Sign Source # 
Instance details

Defined in LibBF.Mutable

Methods

(==) :: Sign -> Sign -> Bool #

(/=) :: Sign -> Sign -> Bool #

Ord Sign Source # 
Instance details

Defined in LibBF.Mutable

Methods

compare :: Sign -> Sign -> Ordering #

(<) :: Sign -> Sign -> Bool #

(<=) :: Sign -> Sign -> Bool #

(>) :: Sign -> Sign -> Bool #

(>=) :: Sign -> Sign -> Bool #

max :: Sign -> Sign -> Sign #

min :: Sign -> Sign -> Sign #

Show Sign Source # 
Instance details

Defined in LibBF.Mutable

Methods

showsPrec :: Int -> Sign -> ShowS #

show :: Sign -> String #

showList :: [Sign] -> ShowS #

Arithmetic

bfNeg :: BigFloat -> BigFloat Source #

Negate a floating point number.

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.

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.

bfMul2Exp :: BFOpts -> BigFloat -> Int64 -> (BigFloat, Status) Source #

Multiply a number by 2^e.

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 :: BFOpts -> BigFloat -> (BigFloat, Status) Source #

Round to an integer using the given parameters.

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