ghc-scientific - Numbers represented using scientific notation
|Distribution||openSUSE Leap 15.1|
|Repository||openSUSE Oss all|
|Download size||76.85 KB|
|Installed size||350.96 KB|
"Data.Scientific" provides the number type 'Scientific'. Scientific numbers are arbitrary precision and space efficient. They are represented using <http://en.wikipedia.org/wiki/Scientific_notation scientific notation>. The implementation uses a coefficient 'c :: 'Integer'' and a base-10 exponent 'e :: 'Int''. A scientific number corresponds to the '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 the 'gcd' of the 'numerator' and 'denominator'. * '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 * Also, the space usage of converting scientific numbers with huge exponents to ''Integral's' (like: 'Int') or ''RealFloat's' (like: 'Double' or 'Float') will always be bounded by the target type.
Install ghc-scientific rpm package:
# zypper install ghc-scientific
2018-10-20 - Peter Simons <firstname.lastname@example.org> - Use https URL to refer to bugs.opensuse.org.
2018-07-18 - email@example.com - Cosmetic: replace tabs with blanks, strip trailing white space, and update copyright headers with spec-cleaner.
2018-05-14 - firstname.lastname@example.org - Update scientific to version 0.3.6.2. * Due to a regression introduced in 0.3.4.14 the RealFrac methods and floatingOrInteger became vulnerable to a space blowup when applied to scientifics with huge exponents. This has now been fixed again. * Fix build on GHC < 8. * Make the methods of the Hashable, Eq and Ord instances safe to use when applied to scientific numbers coming from untrusted sources. Previously these methods first converted their arguments to Rational before applying the operation. This is unsafe because converting a Scientific to a Rational could fill up all space and crash your program when the Scientific has a huge base10Exponent. Do note that the hash computation of the Hashable Scientific instance has been changed because of this improvement! Thanks to Tom Sydney Kerckhove (@NorfairKing) for pushing me to fix this. * fromRational :: Rational -> Scientific now throws an error instead of diverging when applied to a repeating decimal. This does mean it will consume space linear in the number of digits of the resulting scientific. This makes "fromRational" and the other Fractional methods "recip" and "/" a bit safer to use. * To get the old unsafe but more efficient behaviour the following function was added: unsafeFromRational :: Rational -> Scientific. * Add alternatives for fromRationalRepetend: fromRationalRepetendLimited :: Int -- ^ limit - > Rational - > Either (Scientific, Rational) (Scientific, Maybe Int) and: fromRationalRepetendUnlimited :: Rational -> (Scientific, Maybe Int) Thanks to Ian Jeffries (@seagreen) for the idea. * Dropped upper version bounds of dependencies because it's to much work to maintain.
2017-07-11 - email@example.com - Update to version 0.3.5.1.
2017-07-03 - firstname.lastname@example.org - Update to version 0.3.4.15 revision 2.
2017-06-12 - email@example.com - Update to version 0.3.4.15.
2017-05-31 - firstname.lastname@example.org - Update to version 0.3.4.13.
2017-04-19 - email@example.com - Update to version 0.3.4.12 with cabal2obs.
2017-04-04 - firstname.lastname@example.org - Update to version 0.3.4.11 with cabal2obs.
2017-02-12 - email@example.com - Update to version 0.3.4.10 with cabal2obs.