-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A variety of mathematical utilities -- -- A variety of mathematical utilities not covered in base. @package math-extras @version 0.1.1.0 -- | Arithmetic on integral numbers. module Math.Extras.Int -- | Like fromInteger, but returns maxBound and -- minBound in case of overflow and underflow, respectively. saturatedFromInteger :: forall a. (Integral a, Bounded a) => Integer -> a -- | Sum of two integral numbers. Returns maxBound and -- minBound in case of overflow and underflow, respectively. saturatedAdd :: (Integral a, Bounded a) => a -> a -> a -- | Difference of two integral numbers. Returns maxBound and -- minBound in case of overflow and underflow, respectively. saturatedSubtract :: (Integral a, Bounded a) => a -> a -> a -- | Product of two integral numbers. Returns maxBound and -- minBound in case of overflow and underflow, respectively. saturatedMultiply :: (Integral a, Bounded a) => a -> a -> a -- | saturatedPow a b computes a ^ b. -- Returns maxBound and minBound in case of overflow and -- underflow, respectively. -- -- NB: Like ^, the exponent must be non-negative. saturatedPow :: Int -> Int -> Int -- | Returns the bit representation of the input as a NonEmpty -- Char consisting of 0s and 1s, without leading -- zeros. The length of the result is at most finiteBitSize -- b. -- --
--   Data.List.NonEmpty.toList (toBinaryString (100 :: Int)) == "1100100"
--   Data.List.NonEmpty.toList (toBinaryString (-1 :: Int8)) == "11111111"
--   
toBinaryString :: FiniteBits b => b -> NonEmpty Char -- | Arithmetic on doubles. Some functions use more general types than -- Double. module Math.Extras.Double -- | A constant holding the positive infinity of type Double. positiveInfinity :: Double -- | A constant holding the negative infinity of type Double. negativeInfinity :: Double -- | A constant holding a NaN value of type Double. nan :: Double type Tolerance = Double -- | Returns True if the difference of the two numbers are no more -- than abs(tolerance). -- -- -- -- fuzzyEq tolerance is reflexive and symmetric, but not -- transitive unless tolerance is zero, positiveInfinity, -- negativeInfinity, or NaN. fuzzyEq :: Tolerance -> Double -> Double -> Bool -- | Compare two Doubles with a tolerance. -- -- If fuzzyEq tolerance x y then fuzzyCompare -- tolerance x y == EQ; otherwise fuzzyCompare tolerance -- x y == compare x y. fuzzyCompare :: Tolerance -> Double -> Double -> Ordering -- | (~=) is equivalent to fuzzyEq 1.0e-6. (~=) :: Double -> Double -> Bool -- | x /~= y is equivalent to not (x ~= y). (/~=) :: Double -> Double -> Bool data RoundingMode -- | Round away from 0 Up :: RoundingMode -- | Round towards 0 Down :: RoundingMode -- | Round towards positive infinity Ceiling :: RoundingMode -- | Round towards negative infinity Floor :: RoundingMode -- | Round towards nearest integer; round Up in case of a tie HalfUp :: RoundingMode -- | Round towards nearest integer; round Down in case of a tie HalfDown :: RoundingMode -- | Round towards nearest integer; round towards the even neighbor in case -- of a tie HalfEven :: RoundingMode -- | Round a Double to an Integer using the specified -- RoundingMode. roundToInteger :: RoundingMode -> Double -> Integer -- | Round a Double to an integral number using the specified -- RoundingMode. Returns maxBound and minBound in -- case of overflow and underflow, respectively. saturatedRound :: forall a. (Bounded a, Integral a) => RoundingMode -> Double -> a -- | Returns False for NaN and infinity, and True -- otherwise. isFinite :: RealFloat a => a -> Bool -- | Returns True if the input represents an integer. isInteger :: (Eq a, Num a, RealFloat a) => a -> Bool -- | Returns an Int64 with the same bit representation as the given -- Double. toInt64RawBits :: Double -> Int64 -- | Returns a Word64 with the same bit representation as the given -- Double. toWord64RawBits :: Double -> Word64 -- | Returns a Double with the same bit representation as the given -- Int64. fromInt64RawBits :: Int64 -> Double -- | Returns a Double with the same bit representation as the given -- Word64. fromWord64RawBits :: Word64 -> Double instance GHC.Show.Show Math.Extras.Double.RoundingMode instance GHC.Classes.Ord Math.Extras.Double.RoundingMode instance GHC.Classes.Eq Math.Extras.Double.RoundingMode