numeric-prelude-0.1.3: An experimental alternative hierarchy of numeric type classesSource codeContentsIndex
Number.Positional.Check
Stabilityprovisional
Maintainernumericprelude@henning-thielemann.de
Contents
basic helpers
conversions
Description
Interface to Number.Positional which dynamically checks for equal bases.
Synopsis
data T = Cons {
base :: Int
exponent :: Int
mantissa :: Mantissa
}
compress :: T -> T
carry :: T -> T
prependDigit :: Int -> T -> T
lift0 :: (Int -> T) -> T
lift1 :: (Int -> T -> T) -> T -> T
lift2 :: (Int -> T -> T -> T) -> T -> T -> T
commonBasis :: Basis -> Basis -> Basis
fromBaseInteger :: Int -> Integer -> T
fromBaseRational :: Int -> Rational -> T
defltBaseRoot :: Basis
defltBaseExp :: Exponent
defltBase :: Basis
defltShow :: T -> String
legacyInstance :: a
Documentation
data T Source
The value Cons b e m represents the number b^e * (m!!0 / 1 + m!!1 / b + m!!2 / b^2 + ...). The interpretation of exponent is chosen such that floor (logBase b (Cons b e m)) == e. That is, it is good for multiplication and logarithms. (Because of the necessity to normalize the multiplication result, the alternative interpretation wouldn't be more complicated.) However for base conversions, roots, conversion to fixed point and working with the fractional part the interpretation b^e * (m!!0 / b + m!!1 / b^2 + m!!2 / b^3 + ...) would fit better. The digits in the mantissa range from 1-base to base-1. The representation is not unique and cannot be made unique in finite time. This way we avoid infinite carry ripples.
Constructors
Cons
base :: Int
exponent :: Int
mantissa :: Mantissa
show/hide Instances
basic helpers
compress :: T -> TSource
Shift digits towards zero by partial application of carries. E.g. 1.8 is converted to 2.(-2) If the digits are in the range (1-base, base-1) the resulting digits are in the range ((1-base)2-2, (base-1)2+2). The result is still not unique, but may be useful for further processing.
carry :: T -> TSource
perfect carry resolution, works only on finite numbers
prependDigit :: Int -> T -> TSource
conversions
lift0 :: (Int -> T) -> TSource
lift1 :: (Int -> T -> T) -> T -> TSource
lift2 :: (Int -> T -> T -> T) -> T -> T -> TSource
commonBasis :: Basis -> Basis -> BasisSource
fromBaseInteger :: Int -> Integer -> TSource
fromBaseRational :: Int -> Rational -> TSource
defltBaseRoot :: BasisSource
defltBaseExp :: ExponentSource
defltBase :: BasisSource
defltShow :: T -> StringSource
legacyInstance :: aSource
Produced by Haddock version 2.4.2