scientific: Numbers represented using scientific notation
This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.
Warnings:
- 'ghc-options: -O2' is rarely needed. Check that it is giving a real benefit and not just imposing longer compile times on your users.
Data.Scientific provides the number type Scientific
. Scientific numbers are
arbitrary precision and space efficient. They are represented using
scientific notation.
The implementation uses a coefficient c ::
and a base-10 exponent
Integer
e ::
. A scientific number corresponds to the
Int
Fractional
number:
.fromInteger
c * 10 ^^
e
Note that since we're using an Int
to represent the exponent these numbers
aren't truly arbitrary precision. I intend to change the type of the exponent
to Integer
in a future release.
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 thegcd
of thenumerator
anddenominator
.Scientific
is safe against numbers with huge exponents. For example:1e1000000000 ::
will fill up all space and crash your program. Scientific works as expected:Rational
>>>
read "1e1000000000" :: Scientific
1.0e1000000000
Also, the space usage of converting scientific numbers with huge exponents to
(like:Integral
sInt
) or
(like:RealFloat
sDouble
orFloat
) will always be bounded by the target type.
Properties
Modules
[Index] [Quick Jump]
- Data
- ByteString
- Data.Scientific
- Text
- Lazy
Flags
Automatic Flags
Name | Description | Default |
---|---|---|
bytestring-builder | Depend on the bytestring-builder package for backwards compatibility. | Disabled |
integer-simple | Use the integer-simple package instead of integer-gmp | Disabled |
Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info
Downloads
- scientific-0.3.7.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
Package maintainers
For package maintainers and hackage trustees