Numeric.IEEE

ieee754-0.8.0: Utilities for dealing with IEEE floating point numbers

Copyright | Copyright (c) 2010, Patrick Perry <patperry@gmail.com>
License | BSD3
Maintainer | Patrick Perry <patperry@gmail.com>
Stability | experimental
Safe Haskell | None
Language | Haskell98

Numeric.IEEE

Contents

- IEEE type class
- NaN-aware minimum and maximum

Description

Operations on IEEE floating point numbers.

Synopsis

- class RealFloat a => IEEE a where
- minNum :: RealFloat a => a -> a -> a
- maxNum :: RealFloat a => a -> a -> a
- minNaN :: RealFloat a => a -> a -> a
- maxNaN :: RealFloat a => a -> a -> a

# IEEE type class

class RealFloat a => IEEE a where #

IEEE floating point types.

Minimal complete definition

infinity, minDenormal, minNormal, maxFinite, epsilon, copySign, identicalIEEE, succIEEE, predIEEE, bisectIEEE, sameSignificandBits, nan, nanWithPayload, maxNaNPayload, nanPayload

Methods

infinity :: a #

Infinity value.

minDenormal :: a #

The smallest representable positive value.

minNormal :: a #

The smallest representable positive normalized value.

maxFinite :: a #

The largest representable finite value.

epsilon :: a #

The smallest positive value `x` such that `1 + x` is representable.

copySign :: a -> a -> a #

`copySign x y` returns `x` with its sign changed to `y`'s.

identicalIEEE :: a -> a -> Bool #

Return `True` if two values are exactly (bitwise) equal.

succIEEE :: a -> a #

Return the next largest IEEE value (`Infinity` and `NaN` are unchanged).

predIEEE :: a -> a #

Return the next smallest IEEE value (`-Infinity` and `NaN` are unchanged).

bisectIEEE :: a -> a -> a #

Given two values with the same sign, return the value halfway between them on the IEEE number line. If the signs of the values differ or either is `NaN`, the value is undefined.

sameSignificandBits :: a -> a -> Int #

The number of significand bits which are equal in the two arguments (equivalent to `feqrel` from the Tango Math library). The result is between `0` and ``floatDigits``.

nan :: a #

Default `NaN` value.

nanWithPayload :: Word64 -> a #

Quiet `NaN` value with a positive integer payload. Payload must be less than `maxNaNPayload`. Beware that while some platforms allow using `0` as a payload, this behavior is not portable.

maxNaNPayload :: a -> Word64 #

Maximum `NaN` payload for type `a`.

nanPayload :: a -> Word64 #

The payload stored in a `NaN` value. Undefined if the argument is not `NaN`.

Instances

IEEE Double # |
Methods infinity :: Double # minDenormal :: Double # minNormal :: Double # maxFinite :: Double # epsilon :: Double # copySign :: Double -> Double -> Double # identicalIEEE :: Double -> Double -> Bool # succIEEE :: Double -> Double # predIEEE :: Double -> Double # bisectIEEE :: Double -> Double -> Double # sameSignificandBits :: Double -> Double -> Int # nan :: Double # nanWithPayload :: Word64 -> Double # maxNaNPayload :: Double -> Word64 # nanPayload :: Double -> Word64 #
IEEE Float # |
Methods infinity :: Float # minDenormal :: Float # minNormal :: Float # maxFinite :: Float # epsilon :: Float # copySign :: Float -> Float -> Float # identicalIEEE :: Float -> Float -> Bool # succIEEE :: Float -> Float # predIEEE :: Float -> Float # bisectIEEE :: Float -> Float -> Float # sameSignificandBits :: Float -> Float -> Int # nan :: Float # nanWithPayload :: Word64 -> Float # maxNaNPayload :: Float -> Word64 # nanPayload :: Float -> Word64 #
IEEE CFloat # |
Methods infinity :: CFloat # minDenormal :: CFloat # minNormal :: CFloat # maxFinite :: CFloat # epsilon :: CFloat # copySign :: CFloat -> CFloat -> CFloat # identicalIEEE :: CFloat -> CFloat -> Bool # succIEEE :: CFloat -> CFloat # predIEEE :: CFloat -> CFloat # bisectIEEE :: CFloat -> CFloat -> CFloat # sameSignificandBits :: CFloat -> CFloat -> Int # nan :: CFloat # nanWithPayload :: Word64 -> CFloat # maxNaNPayload :: CFloat -> Word64 # nanPayload :: CFloat -> Word64 #
IEEE CDouble # |
Methods infinity :: CDouble # minDenormal :: CDouble # minNormal :: CDouble # maxFinite :: CDouble # epsilon :: CDouble # copySign :: CDouble -> CDouble -> CDouble # identicalIEEE :: CDouble -> CDouble -> Bool # succIEEE :: CDouble -> CDouble # predIEEE :: CDouble -> CDouble # bisectIEEE :: CDouble -> CDouble -> CDouble # sameSignificandBits :: CDouble -> CDouble -> Int # nan :: CDouble # nanWithPayload :: Word64 -> CDouble # maxNaNPayload :: CDouble -> Word64 # nanPayload :: CDouble -> Word64 #

# NaN-aware minimum and maximum

minNum :: RealFloat a => a -> a -> a #

Return the minimum of two values; if one value is `NaN`, return the other. Prefer the first if both values are `NaN`.

maxNum :: RealFloat a => a -> a -> a #

Return the maximum of two values; if one value is `NaN`, return the other. Prefer the first if both values are `NaN`.

minNaN :: RealFloat a => a -> a -> a #

Return the minimum of two values; if one value is `NaN`, return it. Prefer the first if both values are `NaN`.

maxNaN :: RealFloat a => a -> a -> a #

Return the maximum of two values; if one value is `NaN`, return it. Prefer the first if both values are `NaN`.