Numerus
v2.0.0
Roman numerals conversion and manipulation C library.
|
C
means 100
.[-3999, 3999]
that are written with underscores representing the overlined notation - where overlined characters have their values multiplied by 1000.This is a short explanation on how roman numerals work. For a different one, check the Wikipedia article on them.
Roman numerals are sequences of characters from the latin alphabet and each represents a different value:
Char | Value |
---|---|
M | 1000 |
D | 500 |
C | 100 |
L | 50 |
X | 10 |
V | 5 |
I | 1 |
S | 1/2 |
. | 1/12 |
When a character with a smaller value is placed before a character with bigger value (except for S
and .
), they have to be interpreted together as one and their value have to be computed by subtraction bigger - smaller, resulting in:
Char | Value |
---|---|
CM | 900 |
CD | 400 |
XC | 90 |
XL | 40 |
IX | 9 |
IV | 4 |
The rules to read and write roman numerals are:
An example:
The syntax of a standard roman numeral requires a specific sequence of characters as in the following points:
Please notice that there are no S
or .
in it. This allows writing integer values in [1, 3999]
. In a regex form it would be:
Numerus add more syntax rules, while keeping compatibility with the standard roman numeral syntax, with the goal of writing numerals with more values.
Numerus uses the string NULLA
(as stored in the global constant variable NUMERUS_ZERO
) for the numeral of value 0 (zero). The word nulla means nothing in latin.
This allows writing integer values in [0, 3999]
.
Numerus uses the minus -
sign at the beginning of a roman numeral to indicate that its value is negative. This allows writing integer values in [-3999, 3999]
.
An example:
In ancient Rome, positive values bigger than 3999 were indicated with an overlining, called vinculum. The overlined characters have their value multiplied by 1000.
An example:
Numerus adopted this syntax with a difference: instead of actually overlining the characters, making them impossible to parse, encloses the characters that should be overlined with underscores _
. This allows a simple record of characters with values that have to be multiplied by 1000. Creating an actually overlined numeral (a two-line string with underscores in the first line) is possible with the numeral prettifying function.
These are called long numerals in the Numerus nomenclature, resembling the name of a long int
value they represent. This allows writing integer values in [-3999999, 3999999]
.
Long numerals have have the following syntax:
M
An example:
Roman numerals provide fractional values in twelfths (1/12) using the character central dot •
to indicate a twelfth. Numerus uses the normal dot (period) .
instead for simplicity. The character S
is used to indicate one half (6/12) - S
stands for semis, which means half in latin.
Numerus implements that feature allowing a fractional part in all roman numerals (except NULLA
) just by adding S
or .
at the end of the numeral. These are called float numerals in the Numerus nomenclature, resembling the name of a float
value they approximate. This allows writing all twelfths values in [-3999999.91666, 3999999.91666]
.
Float numerals have have the following syntax:
S
to indicate a fractional part of one half (6/12) or more, if that is the case;.
to indicate additional 1 to 5 twelfths.Please note that a float numeral can be at the same time a long numeral and vice-versa. The nomenclature is a pure formality to indicate the capability of the numeral.
Just for the documentation a regex matching all long, float, negative and standard roman numerals but not (-
)NULLA
is: