Portability | portable |
---|---|

Stability | experimental |

Maintainer | Aleksey Khudyakov <alexey.skladnoy@gmail.com> |

Safe Haskell | None |

Different implementations of approximate equality for floating point values. There are multiple ways to implement approximate equality. They have different semantics and it's up to programmer to choose right one.

- eqRelative :: (Fractional a, Ord a) => a -> a -> a -> Bool
- eqRelCompl :: (RealFloat a, Ord a) => a -> Complex a -> Complex a -> Bool
- eqAbsolute :: (Num a, Ord a) => a -> a -> a -> Bool
- within :: Int -> Double -> Double -> Bool

# Documentation

:: (Fractional a, Ord a) | |

=> a | Relative precision |

-> a | |

-> a | |

-> Bool |

Relative difference between two numbers are less than predefined value. For example 1 is approximately equal to 1.0001 with 1e-4 precision. Same is true for 10000 and 10001.

This method of camparison doesn't work for numbers which are
approximately 0. `eqAbsolute`

should be used instead.

Relative equality for comlex numbers.

Difference between values is less than specified precision.

Compare two `Double`

values for approximate equality, using
Dawson's method.

The required accuracy is specified in ULPs (units of least
precision). If the two numbers differ by the given number of ULPs
or less, this function returns `True`

.

Algorithm is based on Bruce Dawson's "Comparing floating point numbers": http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm