1 -- | Functions for comparing 'Double' values.
5 -- | epsilon is the value that will be used in all tests that require
6 -- some measure of \"closeness.\" Increasing it will make those
7 -- tests more tolerant.
12 -- | x almost equals y if x is within 'epsilon' of y.
13 almost_equals :: Double -> Double -> Bool
14 almost_equals x y = (abs (x - y)) < epsilon
17 (~=) :: Double -> Double -> Bool
21 -- | Like 'almost_equals', except much more tolerant. The difference
22 -- between the two arguments must be less than one percent of the sum
23 -- of their magnitudes.
24 kinda_equals :: Double -> Double -> Bool
26 (abs (x - y)) < threshold
28 threshold = ((abs x) + (abs y)) / 100.0
31 (~~=) :: Double -> Double -> Bool
35 -- | x is very positive if it is 'epsilon' greater than zero.
36 very_positive :: Double -> Bool
37 very_positive x = x - epsilon > 0
40 -- | Takes a list of 'Double' and returns the ones which are not very
42 non_very_positive_entries :: [Double] -> [Double]
43 non_very_positive_entries = filter (not . very_positive)