X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FComparisons.hs;h=d033159f23f827fa3776ca2c6dd2ac775780af91;hb=f877af8565db22a047214827d44c4435f96385d5;hp=6d8dc70d846e08159c9c4ae6ea49b11a530a25a2;hpb=8c8a0f9d8df50b2fe29562790360dd615cf3e56a;p=spline3.git diff --git a/src/Comparisons.hs b/src/Comparisons.hs index 6d8dc70..d033159 100644 --- a/src/Comparisons.hs +++ b/src/Comparisons.hs @@ -8,6 +8,17 @@ where epsilon :: Double epsilon = 0.0001 +-- | A tiny margin of error. +theta :: Double +theta = 0.0000000000001 + +-- | x almost equals y if x is within 'theta' of y. +nearly_equals :: Double -> Double -> Bool +nearly_equals x y = (abs (x - y)) < theta + +-- | Nearly greater-than or equal-to. +nearly_ge :: Double -> Double -> Bool +x `nearly_ge` y = (x > y) || (x `nearly_equals` y) -- | x almost equals y if x is within 'epsilon' of y. almost_equals :: Double -> Double -> Bool