exp-extended-0.2: floating point with extended exponent range

Safe HaskellSafe
LanguageHaskell2010

Numeric.ExpExtended

Description

Extend floating point types with a larger exponent range.

Synopsis

Documentation

class RealFloat a => ExpExtendable a where Source #

Extend floating point types with a larger exponent range.

Implementors need only implement:

Using a data family allows the UNPACK optimisation.

Minimal complete definition

unsafeExpExtended, withExpExtended

Associated Types

data ExpExtended a Source #

Associated data.

Instances: Enum, Eq, Floating, Fractional, Num, Ord, Read, Real, RealFloat, RealFrac, Show

Methods

withExpExtended :: ExpExtended a -> (a -> Int -> r) -> r Source #

Deconstruct into basic value and exponent.

unsafeExpExtended :: a -> Int -> ExpExtended a Source #

Construct from a basic value and an exponent, without checking the invariant. Use expExtended instead.

cache :: Cache a Source #

Cache of magic values. Stored once per instance to avoid recomputation.

expExtended :: a -> Int -> ExpExtended a Source #

Construct from a basic value and an exponent, ensuring that the result establishes the internal invariant:

m == significand m && ((m == 0 || isInfinite m || isNaN m) ==> e == 0)

Also handles overflow to infinity, and underflow to zero.

expExtended' :: ExpExtendable a => a -> ExpExtended a Source #

Extend the exponent range while preserving the value.

expExtended' x == expExtended x 0

unExpExtendable :: ExpExtendable a => ExpExtended a -> Bool Source #

Does the extended value fit in the base type without over/underflow?

unExpExtended :: ExpExtendable a => ExpExtended a -> a Source #

Scale to the base type (possibly overflowing to infinity or underflowing to zero).