on 0.8.0.2 help sign in
typeable/aeson/tests/Functions.hs
10 lines 342 B history raw
1module Functions where
3approxEq :: (Fractional a, Ord a) => a -> a -> Bool
4approxEq = approxEqWith 1e-15 1e-15
6approxEqWith :: (Fractional a, Ord a) => a -> a -> a -> a -> Bool
7approxEqWith maxAbsoluteError maxRelativeError a b =
8 a == b || d < maxAbsoluteError ||
9 d / max (abs b) (abs a) <= maxRelativeError
10 where d = abs (a - b)