scientific
Version 0.3.0.0 revision 1 uploaded by HerbertValerioRiedel.
Package meta
- Synopsis
- Numbers represented using scientific notation
- Description
Data.Scientific
provides a space efficient and arbitrary precision scientific number type.Scientific numbers are represented using scientific notation. It uses a coefficient
c :: Integer
and a base-10 exponente :: Int
(do note that since we're using an Int to represent the exponent these numbers aren't truly arbitrary precision). A scientific number corresponds to the Fractional number:fromInteger c * 10 ^^ e
.The main application of Scientific is to be used as the target of parsing arbitrary precision numbers coming from an untrusted source. The advantages over using Rational for this are that:
A Scientific is more efficient to construct. Rational numbers need to be constructed using % which has to compute the gcd of the numerator and denominator. Scientific numbers only need to be normalized, i.e.
10000000
to1e7
.Scientific is safe against numbers with huge exponents. For example:
1e1000000000 :: Rational
will fill up all space and crash your program. Scientific works as expected:
> read "1e1000000000" :: Scientific 1.0e1000000000
- Author
- Bas van Dijk
- Bug reports
- https://github.com/basvandijk/scientific/issues
- Category
- Data
- Copyright
- n/a
- Homepage
- https://github.com/basvandijk/scientific
- Maintainer
- Bas van Dijk <v.dijk.bas@gmail.com>
- Package URL
- n/a
- Stability
- n/a