variable-precision-0.2.1: variable-precision floating point

PortabilityBangPatterns, DeriveDataTypeable, Rank2Types, MonoLocalBinds
Stabilityunstable
Maintainerclaudiusmaximus@goto10.org
Safe HaskellSafe-Infered

Numeric.VariablePrecision.Fixed

Description

Variable precision software fixed point based on Integer.

Accuracy has not been extensively verified.

Example:

 reifyPrecision 1000 $ \prec ->
    show $ auto (355 :: VFixed N15) / 113 `atPrecision` prec

Synopsis

Documentation

data VFixed p Source

A software implementation of fixed point arithmetic, using an Integer adjusted to p bits after the binary point.

data DFixed Source

A concrete format suitable for storage or wire transmission.

Constructors

DFixed 

fromDFixed :: NaturalNumber p => DFixed -> Maybe (VFixed p)Source

Thaw a DFixed. Results in Nothing on precision mismatch.

withDFixed :: DFixed -> (forall p. NaturalNumber p => VFixed p -> r) -> rSource

Thaw a DFixed to its natural precision.