fixedprec-0.2: A fixed-precision real number type

Safe HaskellSafe-Inferred
LanguageHaskell98

Data.Number.FixedPrec

Contents

Description

A reasonably efficient implementation of arbitrary-but-fixed precision real numbers. This is inspired by, and partly based on, Data.Number.Fixed and Data.Number.CReal, but more efficient.

Synopsis

Type-level integers for precision

class Precision e Source

A type class for type-level integers, capturing a precision parameter. Precision is measured in decimal digits.

Minimal complete definition

digits

data P0 Source

Precision of 0 digits.

Instances

data P1 Source

Precision of 1 digit.

Instances

data P10 Source

Precision of 10 digits.

Instances

data P100 Source

Precision of 100 digits.

Instances

data P1000 Source

Precision of 1000 digits.

Instances

data P2000 Source

Precision of 2000 digits.

Instances

data PPlus1 e Source

Add 1 digit to the given precision.

Instances

data PPlus3 e Source

Add 3 digits to the given precision.

Instances

data PPlus10 e Source

Add 10 digits to the given precision.

Instances

data PPlus100 e Source

Add 100 digits to the given precision.

Instances

data PPlus1000 e Source

Add 1000 digits to the given precision.

Instances

Fixed-precision numbers

data FixedPrec e Source

The type of fixed-precision numbers.

getprec :: Precision e => FixedPrec e -> Int Source

Get the precision of a fixed-precision number, in decimal digits.

Static and dynamic casts

cast :: (Precision e, Precision f) => FixedPrec e -> FixedPrec f Source

Cast from any FixedPrec type to another.

upcast :: Precision e => FixedPrec e -> FixedPrec (PPlus3 e) Source

Cast to a fixed-point type with three additional digits of accuracy.

downcast :: Precision e => FixedPrec (PPlus3 e) -> FixedPrec e Source

Cast to a fixed-point type with three fewer digits of accuracy.

with_added_digits :: forall a f. Precision f => Int -> (forall e. Precision e => FixedPrec e -> a) -> FixedPrec f -> a Source

The function with_added_digits d f x evaluates f(x), adding d digits of accuracy to x during the computation.

Other operations

fractional :: Precision e => FixedPrec e -> FixedPrec e Source

Return the positive fractional part of a fixed-precision number. The result is always in [0,1), regardless of the sign of the input.

log_double :: (Floating a, Real a) => a -> Double Source

A version of the natural logarithm that returns a Double. The logarithm of just about any value can fit into a Double; so if not a lot of precision is required in the mantissa, this function is often faster than log.