scientific-notation: Scientific notation intended for tokenization
This library provides a type used to represent a number in
scientific notation. This is most frequently useful when
tokenizing or parsing a language. Languages like JSON and SQL
support numberic literals written in scientific notation, even
though backends frequently reject numbers outside a given range.
This library provides a compact representation of numbers in
scientific notation. In the common case of the coefficient and
then exponent each being small enough to be represented by a
machine word, this library avoids the need for any indirections
to retrieve the number. Consider some tokenization scheme:
`data Token = ... | Number {-# UNPACK #-} !Scientific`.
In this case, the unboxed coefficient and exponent are unpacked
into the Number
data constructor if they can each be represented
by a machine word.
The internal representation does not normalize numbers. That is,
parsing `300e-2` resulting in a representation that uses `300` and
`-2` rather than `3` and `0`.
This work is deferred with the expectation that a number in scientific
notation is consumed either zero or one times. This library is not
optimized for use-cases that consume a Scientific
more than once
since normalization is reapplied every time.
The primary library that operates in this same space is scientific
.
Compared to scientific
, this library distinguishes itself from
scientific
in the following ways:
Correctness:
scientific
does not correctly handle large exponents. See issue #62.Parsing: The `scientific-notation` parser outperforms the
scientific
parser that ships withaeson
by a factor of five on small numbers.
Downloads
- scientific-notation-0.1.7.0.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1.0.0, 0.1.0.1, 0.1.1.0, 0.1.2.0, 0.1.3.0, 0.1.4.0, 0.1.5.0, 0.1.6.0, 0.1.6.1, 0.1.7.0 |
---|---|
Change log | CHANGELOG.md |
Dependencies | base (>=4.17.1 && <5), bytebuild (>=0.3.5 && <0.4), byteslice (>=0.2.6 && <0.3), bytesmith (>=0.3 && <0.4), bytestring (>=0.10.12), natural-arithmetic (>=0.1.1 && <0.3), primitive (>=0.7.1), text-short (>=0.1.3), word-compat (>=0.0.2) [details] |
License | BSD-3-Clause |
Copyright | 2019 Andrew Martin |
Author | Andrew Martin |
Maintainer | amartin@layer3com.com |
Category | Data |
Home page | https://github.com/byteverse/scientific-notation |
Bug tracker | https://github.com/byteverse/scientific-notation/issues |
Source repo | head: git clone git://github.com/byteverse/scientific-notation.git |
Uploaded | by andrewthad at 2024-02-13T16:03:41Z |
Distributions | NixOS:0.1.7.0 |
Reverse Dependencies | 3 direct, 1 indirect [details] |
Downloads | 1956 total (4 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs available [build log] Last success reported on 2024-02-13 [all 1 reports] |