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

Copyright | Copyright (c) 2010 Patrick Perry <patperry@gmail.com>
License | BSD3
Maintainer | Patrick Perry <patperry@gmail.com>
Stability | experimental
Safe Haskell | Safe-Inferred
Language | Haskell98

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.

Minimal complete definition

Nothing

Methods

(===) :: a -> a -> Bool infix 4 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 infix 4 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

Instances details

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