![]() |
Numerus
v2.0.0
Roman numerals conversion and manipulation C library.
|
First of all, include the library header file:
Create a value and an error code variable. Pass both to the conversion function numerus_double_to_roman()
(pass a pointer to the error code). If the error code is NUMERUS_OK, the conversion was successful, otherwise something bad happened, like your value was outside the allowed range or malloc()
failed.
numerus_explain_error()
can help to understand the error, since it prints an explanation of the error for humans.
Remember to free()
the generated roman numeral one you don't need it anymore.
Please be a good programmer and always check your errors!. If you are lazy and your program explodes, don't blame me.
Anyways, error codes can be NULL
to ignore any error. Just pass the value to a conversion function, numerus_int_to_roman()
in this case, and get the result. In case of error, the generated roman numeral will be NULL
. If you dislike error codes, you may always check this.
In case of error, the generated int_part will be bigger than the maximum
Create a roman numeral, a variable to hold a number of twelfths and an error code variable. Pass all of them to the conversion function numerus_roman_to_int_part_and_twelfths()
.
If the error code is NUMERUS_OK, the conversion was successful, otherwise something bad happened, like your roman numeral had incorrect syntax (an illegal character, illegal character order, missing underscore, ...). In that case the returned long integer_part will be bigger than the maximum value a roman numeral may have, NUMERUS_MAX_VALUE. If you dislike error codes, you may always check this. numerus_explain_error()
can help to understand the error, since it prints an explanation of the error for humans.
Remember to free()
the generated roman numeral one you don't need it anymore.
For any other explanation, please contact me - my contact is in the readme file.