libBF-0.5.1: A binding to the libBF library.

Safe HaskellNone
LanguageHaskell2010

LibBF.Opts

Contents

Description

Configuration and results for FP computation.

Synopsis

Options

data BFOpts Source #

Specifies various computation settings, combined with Semigroup.

Constructors

BFOpts !LimbT !FlagsT 
Instances
Semigroup BFOpts Source # 
Instance details

Defined in LibBF.Opts

allowSubnormal :: BFOpts Source #

Allow denormalized answers.

Presets

float16 :: RoundMode -> BFOpts Source #

Precision 11, exponent 5

float32 :: RoundMode -> BFOpts Source #

Precision 24, exponent 8

float64 :: RoundMode -> BFOpts Source #

Precision 53, exponent 11

float128 :: RoundMode -> BFOpts Source #

Precision 113, exponent 15

float256 :: RoundMode -> BFOpts Source #

Precision 237, exponent 19

Precision

precBits :: Int -> BFOpts Source #

Use this many bits to represent the mantissa in the computation. The input should be in the interval defined by precMin and precMax

precBitsMin :: Int Source #

The smallest supported precision (in bits).

precBitsMax :: Int Source #

The largest supported precision (in bits). Memory could run out before we run out of precision.

infPrec :: BFOpts Source #

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).

Exponent Size

expBits :: Int -> BFOpts Source #

Set how many bits to use to represent the exponent. Should fit in the range defined by expBitsMin and expBitsMax.

expBitsMin :: Int Source #

The smallest supported number of bits in the exponent.

expBitsMax :: Int Source #

The largest number of exponent bits supported.

Rounding mode

rnd :: RoundMode -> BFOpts Source #

Use the given rounding mode. If none is specified, then the default is NearEven.

newtype RoundMode Source #

Specifies how to round when the result can't be precise.

Constructors

RoundMode FlagsT 
Instances
Show RoundMode Source # 
Instance details

Defined in LibBF.Opts

pattern NearEven :: RoundMode Source #

Round to nearest, ties go to even.

pattern ToZero :: RoundMode Source #

Round toward zero.

pattern ToNegInf :: RoundMode Source #

Round down (toward -inf).

pattern ToPosInf :: RoundMode Source #

Round up (toward +inf).

pattern NearAway :: RoundMode Source #

Round to nearest, ties go away from zero.

pattern Away :: RoundMode Source #

Round away from zero

pattern Faithful :: RoundMode Source #

Faithful rounding (nondeterministic, either ToPosInf or ToNegInf). The Inexact flag is always set.

Pretty printing options

data ShowFmt Source #

Settings for rendering numbers as String.

Constructors

ShowFmt !LimbT !FlagsT 
Instances
Semigroup ShowFmt Source # 
Instance details

Defined in LibBF.Opts

showRnd :: RoundMode -> ShowFmt Source #

Use this rounding mode.

showFixed :: Word64 -> ShowFmt Source #

Show this many significant digits total .

showFrac :: Word64 -> ShowFmt Source #

Show this many digits after the decimal point.

showFree :: Maybe Word64 -> ShowFmt Source #

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.

showFreeMin :: Maybe Word64 -> ShowFmt Source #

same as showFree but uses the minimum number of digits (takes more computation time).

addPrefix :: ShowFmt Source #

add 0x prefix for base 16, 0o prefix for base 8 or 0b prefix for base 2 if non zero value

forceExp :: ShowFmt Source #

Show in exponential form.

radixMax :: Int Source #

Maximum radix when rendering to a for bf_atof and bf_froa.

Status

newtype Status Source #

A set of flags indicating things that might go wrong.

Constructors

Status CInt 
Instances
Eq Status Source # 
Instance details

Defined in LibBF.Opts

Methods

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

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

Ord Status Source # 
Instance details

Defined in LibBF.Opts

Show Status Source # 
Instance details

Defined in LibBF.Opts

pattern Ok :: Status Source #

Succeeds if everything is OK.

pattern InvalidOp :: Status Source #

We tried to perform an invalid operation.

pattern DivideByZero :: Status Source #

We divided by zero.

pattern Overflow :: Status Source #

The result can't be represented because it is too large.

pattern Underflow :: Status Source #

The result can't be represented because it is too small.

pattern Inexact :: Status Source #

The result is not exact.

pattern MemError :: Status Source #

Memory error. NaN is returned.

Internal

type LimbT = Word64 Source #

Internal: type for limbs

type SLimbT = Int64 Source #

Internal: type for signed limbs

type FlagsT = Word32 Source #

Internal: type for flags