Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
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.
- class Precision e
- data P0
- data P1
- data P10
- data P100
- data P1000
- data P2000
- data PPlus1 e
- data PPlus3 e
- data PPlus10 e
- data PPlus100 e
- data PPlus1000 e
- data FixedPrec e
- getprec :: Precision e => FixedPrec e -> Int
- cast :: (Precision e, Precision f) => FixedPrec e -> FixedPrec f
- upcast :: Precision e => FixedPrec e -> FixedPrec (PPlus3 e)
- downcast :: Precision e => FixedPrec (PPlus3 e) -> FixedPrec e
- with_added_digits :: forall a f. Precision f => Int -> (forall e. Precision e => FixedPrec e -> a) -> FixedPrec f -> a
- fractional :: Precision e => FixedPrec e -> FixedPrec e
- log_double :: (Floating a, Real a) => a -> Double
Type-level integers for precision
A type class for type-level integers, capturing a precision parameter. Precision is measured in decimal digits.
digits
Add 1000 digits to the given precision.
Fixed-precision numbers
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.