connections-0.2.0: Orders, Galois connections, and lattices.
Safe HaskellSafe
LanguageHaskell2010

Data.Connection.Float

Synopsis

Connections

f32i08 :: Conn k Float (Extended Int8) Source #

All Int08 values are exactly representable in a Float.

f32i16 :: Conn k Float (Extended Int16) Source #

All Int16 values are exactly representable in a Float.

ceilingWith f32i16 32767.0

Extended 32767 > ceilingWith f32i16 32767.1 Top

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.

Float

min32 :: Float -> Float -> Float Source #

A NaN-handling min32 function.

min32 x NaN = x
min32 NaN y = y

max32 :: Float -> Float -> Float Source #

A NaN-handling max32 function.

max32 x NaN = x
max32 NaN y = y

ulp32 :: Float -> Float -> Maybe (Ordering, Word32) Source #

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

>>> ulp32 1.0 (shift32 1 1.0)
Just (LT,1)
>>> ulp32 (0.0/0.0) 1.0
Nothing

near32 :: Word32 -> Float -> Float -> Bool Source #

Compare two 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/.

shift32 :: Int32 -> Float -> Float Source #

Shift a float by n units of least precision.

>>> shift32 1 0
1.0e-45
>>> shift32 1 1 - 1
1.1920929e-7
>>> shift32 1 $ 0/0
NaN
>>> shift32 (-1) $ 0/0
NaN
>>> shift32 1 $ 1/0
Infinity

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

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

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

>>> ulp64 1.0 (shift64 1 1.0)
Just (LT,1)
>>> ulp64 (0.0/0.0) 1.0
Nothing

near64 :: 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/.

shift64 :: Int64 -> Double -> Double Source #

Shift by n units of least precision.

>>> shift64 1 0
5.0e-324
>>> shift64 1 1 - 1
2.220446049250313e-16
>>> shift64 1 $ 0/0
NaN
>>> shift64 (-1) $ 0/0
NaN
>>> shift64 1 $ 1/0
Infinity

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