ieee754-0.7.3: Utilities for dealing with IEEE floating point numbers

Stability | experimental
Maintainer | Patrick Perry <patperry@gmail.com>
Safe Haskell | None

Data.AEq

Description

A type class for approximate and exact equalilty comparisons and instances for common data types.

Synopsis

- class Eq a => AEq a where
  - (===) :: a -> a -> Bool
  - (~==) :: a -> a -> Bool

# Documentation

class Eq a => AEq a where Source

Types with approximate and exact equality comparisons.

Methods

(===) :: a -> a -> Bool Source

An exact equality comparison.

For real `IEEE` types, two values are equivalent in the following cases:

- both values are `+0`;
- both values are `-0`;
- both values are nonzero and equal to each other (according to `==`);
- both values are `NaN` with the same payload and sign.

For complex `IEEE` types, two values are equivalent if their real and imaginary parts are equivalent.

(~==) :: a -> a -> Bool Source

An approximate equality comparison operator.

For real `IEEE` types, two values are approximately equal in the following cases:

- at least half of their significand bits agree;
- both values are less than `epsilon`;
- both values are `NaN`.

For complex `IEEE` types, two values are approximately equal in the followiing cases:

- their magnitudes are approximately equal and the angle between them is less than `32*`epsilon``;
- both magnitudes are less than `epsilon`;
- both have a `NaN` real or imaginary part.

Admitedly, the `32` is a bit of a hack. Future versions of the library may switch to a more principled test of the angle.

Instances

AEq Bool |
AEq Char |
AEq Double |
AEq Float |
AEq Int |
AEq Int8 |
AEq Int16 |
AEq Int32 |
AEq Int64 |
AEq Integer |
AEq Ordering |
AEq Word |
AEq Word8 |
AEq Word16 |
AEq Word32 |
AEq Word64 |
AEq () |
AEq WordPtr |
AEq IntPtr |
AEq CChar |
AEq CSChar |
AEq CUChar |
AEq CShort |
AEq CUShort |
AEq CInt |
AEq CUInt |
AEq CLong |
AEq CULong |
AEq CLLong |
AEq CULLong |
AEq CFloat |
AEq CDouble |
AEq CPtrdiff |
AEq CSize |
AEq CWchar |
AEq CSigAtomic |
AEq CClock |
AEq CTime |
AEq CIntPtr |
AEq CUIntPtr |
AEq CIntMax |
AEq CUIntMax |
AEq a => AEq [a] |
AEq (StablePtr a) |
AEq (Ptr a) |
AEq (FunPtr a) |
AEq (Complex Double) |
AEq (Complex Float) |
AEq (Complex CFloat) |
AEq (Complex CDouble) |
AEq (ForeignPtr a) |
AEq a => AEq (Maybe a) |
(AEq a, AEq b) => AEq (Either a b) |
(AEq a, AEq b) => AEq (a, b) |
(AEq a, AEq b, AEq c) => AEq (a, b, c) |
(AEq a, AEq b, AEq c, AEq d) => AEq (a, b, c, d) |
(AEq a, AEq b, AEq c, AEq d, AEq e) => AEq (a, b, c, d, e) |
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f) => AEq (a, b, c, d, e, f) |
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g) => AEq (a, b, c, d, e, f, g) |
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h) => AEq (a, b, c, d, e, f, g, h) |
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i) => AEq (a, b, c, d, e, f, g, h, i) |
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i, AEq j) => AEq (a, b, c, d, e, f, g, h, i, j) |
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i, AEq j, AEq k) => AEq (a, b, c, d, e, f, g, h, i, j, k) |
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i, AEq j, AEq k, AEq l) => AEq (a, b, c, d, e, f, g, h, i, j, k, l) |
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i, AEq j, AEq k, AEq l, AEq m) => AEq (a, b, c, d, e, f, g, h, i, j, k, l, m) |
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i, AEq j, AEq k, AEq l, AEq m, AEq n) => AEq (a, b, c, d, e, f, g, h, i, j, k, l, m, n) |
(AEq a, AEq b, AEq c, AEq d, AEq e, AEq f, AEq g, AEq h, AEq i, AEq j, AEq k, AEq l, AEq m, AEq n, AEq o) => AEq (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) |