| Stability | experimental |
|---|---|
| Maintainer | Patrick Perry <patperry@stanford.edu> |
Numeric.IEEE
Description
Approximate comparison of floating point numbers based on the algorithm in Section 4.2.2 of Knuth's _Seminumerical Algorithms_ and NaN-aware minimum and maximum.
Relative accuracy within eps is measured using an interval of size 2*r,
where r = 2^k eps, and k is the maximum exponent of x and y. If
x and y lie within this interval, they are considered approximately
equal.
Note that x and y are compared to relative accuracy, so these functions
are not suitable for testing whether a value is approximately zero.
The implementation is based on the GNU Scientific Library implementation,
which is based on the package fcmp by T.C. Belding.
- maxF :: RealFloat a => a -> a -> a
- minF :: RealFloat a => a -> a -> a
- delta :: RealFloat a => a
- epsilon :: RealFloat a => a
- epsilon' :: RealFloat a => a
- eqRel :: RealFloat a => a -> a -> a -> Bool
- neqRel :: RealFloat a => a -> a -> a -> Bool
- ltRel :: RealFloat a => a -> a -> a -> Bool
- lteRel :: RealFloat a => a -> a -> a -> Bool
- gtRel :: RealFloat a => a -> a -> a -> Bool
- gteRel :: RealFloat a => a -> a -> a -> Bool
- compareRel :: RealFloat a => a -> a -> a -> Ordering
NaN-aware minimum and maximum
maxF :: RealFloat a => a -> a -> aSource
A version of max that returns NaN if either argument is NaN.
minF :: RealFloat a => a -> a -> aSource
A version of min that returns NaN if either argument is NaN.
Relative comparisons
delta :: RealFloat a => aSource
A value suitable for relative comparisons when half of of the
digits of precision are important. For Doubles this value is
7.450580596923828e-9.
epsilon :: RealFloat a => aSource
The smallest positive floating-point number x such that 1 + x != 1.
Suitable for relative comparisons when all but the least significant digit
of precision are important. For Doubles this value is
2.220446049250313e-16.
epsilon' :: RealFloat a => aSource
The smallest positive floating-point number x such that 1 - x != 1.
Suitable for relative comparisons when one number is exact and all but the
least significant digit of precision in the other number are important.
For Doubles this value is 1.1102230246251565e-16.
eqRel :: RealFloat a => a -> a -> a -> BoolSource
eqRel eps x y. Relative equality comparator.
Returns False if either argument is NaN.
neqRel :: RealFloat a => a -> a -> a -> BoolSource
neqRel eps x y. Relative inequality comparator.
Returns False if either argument is NaN.
ltRel :: RealFloat a => a -> a -> a -> BoolSource
ltRel eps x y. Relative less-than comparator.
Returns False if either argument is NaN.
lteRel :: RealFloat a => a -> a -> a -> BoolSource
lteRel eps x y. Relative less-than-or-equal-to comparator.
Returns False if either argument is NaN.
gtRel :: RealFloat a => a -> a -> a -> BoolSource
gtRel eps x y. Relative greater-than comparator.
Returns False if either argument is NaN.
gteRel :: RealFloat a => a -> a -> a -> BoolSource
gteRel eps x y. Relative greater-than-or-equal-to comparator.
Returns False if either argument is NaN.
compareRel :: RealFloat a => a -> a -> a -> OrderingSource
compareRel eps x y gives an ordering of x and y based on a
relative comparison of accuracy eps. This will call error if either
argument is NaN.