goatee-0.4.0: A monadic take on a 2,500-year-old board game - library.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Game.Goatee.Common.Bigfloat

Description

Base-10 arbitrary-precision floating-point numbers.

Synopsis

Documentation

data Bigfloat Source #

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 significand f * (10 ^ exponent f). The exponent is a limited-precision 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 Doubles to Bigfloats.

encode :: Integer -> Int -> Bigfloat Source #

encode significand exponent creates a Bigfloat value whose numeric value is significand * (10 ^ exponent).

fromDouble :: Double -> Bigfloat Source #

Converts a Double to a Bigfloat (with as much precision as the Double Show instance provides).

toDouble :: Bigfloat -> Double Source #

Converts a Bigfloat to a Double, lossily.