Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Game.Goatee.Common.Bigfloat
Description
Base-10 arbitrary-precision floating-point numbers.
Documentation
A base-10, infinite-precision, floating-point number. Implemented as an
infinite-precision significand together with an exponent, such that the
numeric value is equal to
. The
exponent is a limited-precision significand
f * (10 ^ exponent
f)Int
, because some operations may break if
the exponent is larger (specifically show
and toDouble
). This shouldn't
be an issue for Goatee.
These values form an integral domain.
The Show
instance always outputs in decimal notation, never scientific
notation. Examples:
300 (never trailing .0 if there's no fractional part) 0.1 (never redundant trailing or leading zeros)
Similarly, the Read
instance accepts numbers matching the regex
-?\d+(\.\d+)?(e-?\d+)?
. Scientific exponent notation is supported for
reading, for ease of converting Double
s to Bigfloat
s.
encode :: Integer -> Int -> Bigfloat Source #
encode significand exponent
creates a Bigfloat
value whose numeric
value is significand * (10 ^ exponent)
.
significand :: Bigfloat -> Integer Source #
fromDouble :: Double -> Bigfloat Source #