basvandijk/scientific


Arbitrary-precision floating-point numbers represented using scientific notation

License: Other

Language: Haskell

Keywords: haskell, numbers, scientific-notation


Hackage Build Status

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 exponent e :: Int (do note that since we're using an Int to represent the exponent these numbers aren't truly arbitrary precision. I intend to change this to Integer in the future!). 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 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 RealFloats (like: Double or Float) will always be bounded by the target type.

Project Statistics

Sourcerank 9
Repository Size 252 KB
Stars 35
Forks 21
Watchers 3
Open issues 4
Dependencies 0
Contributors 16
Tags 46
Created
Last updated
Last pushed

Top Contributors See all

Bas van Dijk Oleg Grenrus Bryan O'Sullivan Shlok Datye Herbert Valerio Riedel Daisuke Fujimura Ryan Scott Mikhail Glushenkov Artyom Kazak trilogysci David Fox Zejun Wu Maxwell Swadling Edward Betts Adam Bergmark Andrés Sicard-Ramírez

Packages Referencing this Repo

scientific
Data.Scientific provides a space efficient and arbitrary precision scientific number type. Scie...
Latest release 0.3.6.2 - Updated - 35 stars

Recent Tags See all

0.3.6.0 May 06, 2018
0.3.5.3 March 14, 2018
0.3.5.2 August 30, 2017
0.3.5.1 July 07, 2017
0.3.5.0 July 06, 2017
0.3.4.15 June 04, 2017
0.3.4.14 June 04, 2017
0.3.4.13 May 27, 2017
0.3.4.12 April 11, 2017
0.3.4.11 March 27, 2017
0.3.4.11 March 27, 2017
0.3.4.10 January 02, 2017
0.3.4.9 July 11, 2016
0.3.4.8 July 02, 2016
0.3.4.7 June 11, 2016

Something wrong with this page? Make a suggestion

Last synced: 2018-05-09 01:56:39 UTC

Login to resync this repository