connections-0.1.0: Orders, Galois connections, and lattices.

Safe HaskellSafe
LanguageHaskell2010

Data.Connection.Double

Synopsis

Documentation

f64i08 :: Conn k Double (Extended Int8) Source #

All Int08 values are exactly representable in a Double.

f64i16 :: Conn k Double (Extended Int16) Source #

All Int16 values are exactly representable in a Double.

f64i32 :: Conn k Double (Extended Int32) Source #

All Int32 values are exactly representable in a Double.

min64 :: Double -> Double -> Double Source #

A NaN-handling min function.

min64 x NaN = x
min64 NaN y = y

max64 :: Double -> Double -> Double Source #

A NaN-handling max function.

max64 x NaN = x
max64 NaN y = y

ulp :: Double -> Double -> Maybe (Ordering, Word64) Source #

Compute the signed distance between two doubles in units of least precision.

>>> ulp 1.0 (shift 1 1.0)
Just (LT,1)
>>> ulp (0.0/0.0) 1.0
Nothing

covers :: Double -> Double -> Bool Source #

Covering relation on the N5 lattice of doubles.

https://en.wikipedia.org/wiki/Covering_relation

>>> covers 1 (shift 1 1)
True
>>> covers 1 (shift 2 1)
False

shift :: Int64 -> Double -> Double Source #

Shift by n units of least precision.

>>> shift 1 0
1.0e-45
>>> shift 1 $ 0/0
NaN
>>> shift (-1) $ 0/0
NaN
>>> shift 1 $ 1/0
Infinity

within :: Word64 -> Double -> Double -> Bool Source #

Compare two double-precision floats for approximate equality.

Required accuracy is specified in units of least precision.

See also https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/.

epsilon :: Double Source #

Difference between 1 and the smallest representable value greater than 1.

epsilon = shift 1 1 - 1
>>> epsilon
2.220446049250313e-16

until :: (a -> Bool) -> (a -> a -> Bool) -> (a -> a) -> a -> a Source #