-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Approximate comparisons for IEEE floating point numbers -- -- Approximate comparison of floating point numbers based on the -- algorithm in Section 4.2.2 of Knuth's _Seminumerical Algorithms_, -- NaN-aware minimum and maximum, and a type class for approximate -- comparisons. @package ieee @version 0.3 -- | 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. module Numeric.IEEE -- | A version of max that returns NaN if either argument -- is NaN. maxF :: (RealFloat a) => a -> a -> a -- | A version of min that returns NaN if either argument -- is NaN. minF :: (RealFloat a) => a -> a -> a -- | A value suitable for relative comparisons when half of of the digits -- of precision are important. For Doubles this value is -- 7.450580596923828e-9. delta :: (RealFloat a) => a -- | 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) => a -- | 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. epsilon' :: (RealFloat a) => a -- | eqRel eps x y. Relative equality comparator. Returns -- False if either argument is NaN. eqRel :: (RealFloat a) => a -> a -> a -> Bool -- | neqRel eps x y. Relative inequality comparator. Returns -- False if either argument is NaN. neqRel :: (RealFloat a) => a -> a -> a -> Bool -- | ltRel eps x y. Relative less-than comparator. Returns -- False if either argument is NaN. ltRel :: (RealFloat a) => a -> a -> a -> Bool -- | lteRel eps x y. Relative less-than-or-equal-to comparator. -- Returns False if either argument is NaN. lteRel :: (RealFloat a) => a -> a -> a -> Bool -- | gtRel eps x y. Relative greater-than comparator. Returns -- False if either argument is NaN. gtRel :: (RealFloat a) => a -> a -> a -> Bool -- | gteRel eps x y. Relative greater-than-or-equal-to comparator. -- Returns False if either argument is NaN. gteRel :: (RealFloat a) => a -> a -> a -> Bool -- | 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. compareRel :: (RealFloat a) => a -> a -> a -> Ordering -- | A type class for approximate and exact equalilty comparisons and -- instances for common data types. module Data.AEq class (Eq a) => AEq a (===) :: (AEq a) => a -> a -> Bool (~==) :: (AEq a) => a -> a -> Bool compareListsWith :: (a -> a -> Bool) -> [a] -> [a] -> Bool instance (AEq a, AEq b) => AEq (Either a b) instance (AEq a) => AEq (Maybe a) instance (AEq a) => AEq [a] instance (AEq a, AEq b, AEq c, AEq d) => AEq (a, b, c, d) instance (AEq a, AEq b, AEq c) => AEq (a, b, c) instance (AEq a, AEq b) => AEq (a, b) instance AEq () instance AEq Word64 instance AEq Word32 instance AEq Word16 instance AEq Word8 instance AEq Word instance AEq Int64 instance AEq Int32 instance AEq Int16 instance AEq Int8 instance AEq Int instance AEq Bool instance (RealFloat a, AEq a) => AEq (Complex a) instance AEq Double instance AEq Float