Support for various integer-to-numeral conversion.
Project description
This Python library implements integer-to-numeral and numeral-to-integer conversion for a variety of numeral representations, including:
alphabetic representation, i.e. a, b, c, d, … for 0, 1, 2, 3, …
Roman numbers, i.e. I, II, III, IV, … for 1, 2, 3, 4, …
generic tokens set representation, i.e. !, @, !!, !@, … for 0, 1, 2, 3… (given the tokens set {!, @}).
The generic tokens set representation uses the least number of tokens for representing a given integer, and uses an exponential-like notation similar to base-n conversion, except that the first symbol is used. The alphabetic representation is a special case of a generic tokens set representation, where the latin alphabet is used as tokens set. Upper/lower case conversion should be handled through Python built-ins. All representation support negative values.
Detailed documentation is available for all functions through docstrings.
Of note, the Roman numbers support include:
both Unicode and ASCII-only representations
partial support for large numbers via the so-called Apostrophus notation (see: https://en.wikipedia.org/wiki/Roman_numerals#Apostrophus)
additive-only or subtractive notations
toggleable forgiving/strict Roman number parsing
representation of zero (see: https://en.wikipedia.org/wiki/Roman_numerals#Zero)
negative numbers (with option to specify a custom negative sign)
partial support for archaic/late forms (see: https://en.wikipedia.org/wiki/Numerals_in_Unicode#Roman_numerals)
Installation
The recommended way of installing the software is through PyPI:
$ pip install numeral
Alternatively, you can clone the source repository from Bitbucket:
$ mkdir numeral
$ cd numeral
$ git clone git@bitbucket.org:norok2/numeral.git
$ python setup.py install
(some steps may require additional permissions depending on your configuration)
The software does not have additional dependencies beyond Python and its standard library.
It was tested with Python 2.7 and 3.5. Other version were not tested.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for numeral-0.1.0.8-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3efbcc7d0d20bb2265a4f8e8d19ddfc7e357b08c057702e03870402fde0bd365 |
|
MD5 | 47ad3c91292c33671f9ead13359b655c |
|
BLAKE2b-256 | 5789a0561705d6af95c4e1199aa9305e17c5d3083a5a2e3c3ee0599c66607e02 |