Methods
decode(s) → {number}
Decodes an ELEN encoded number back into the original number.
See #encode().
Parameters:
Name | Type | Description |
---|---|---|
s |
string | ELEN encoded number |
Throws:
InvalidArgumentException
Returns:
- Type
- number
encode(n) → {string}
Encodes a number as a string using ELEN encoding.
ELEN encoding has the property that the lexicographical order of a set of ELEN-encoded numbers matches the natural ordering of the original numbers.
Based on the algorithm for efficient lexicographic encoding of natural numbers by Peter Seymour.
ELEN encoding has the property that the lexicographical order of a set of ELEN-encoded numbers matches the natural ordering of the original numbers.
Based on the algorithm for efficient lexicographic encoding of natural numbers by Peter Seymour.
Parameters:
Name | Type | Description |
---|---|---|
n |
number | Number to encode |
Throws:
InvalidArgumentException
Returns:
- Type
- string