Numerus  v2.0.0
Roman numerals conversion and manipulation C library.
numerus.h
Go to the documentation of this file.
1 
12 #include "numerus_error_codes.h"
13 
14 
15 /* Extremes of the value range */
16 extern const double NUMERUS_MAX_VALUE;
17 extern const double NUMERUS_MIN_VALUE;
18 extern const long NUMERUS_MAX_LONG_NONFLOAT_VALUE;
19 extern const long NUMERUS_MIN_LONG_NONFLOAT_VALUE;
20 extern const double NUMERUS_MAX_NONLONG_FLOAT_VALUE;
21 extern const double NUMERUS_MIN_NONLONG_FLOAT_VALUE;
22 
23 
24 /* Special values */
25 extern const short NUMERUS_MAX_LENGTH;
26 extern const char *NUMERUS_ZERO;
27 
28 
29 /* Error code global variable */
30 extern int numerus_error_code;
31 
32 
33 /* Conversion function from value to roman numeral */
34 char *numerus_double_to_roman(double double_value, int *errcode);
35 char *numerus_int_to_roman(long int_value, int *errcode);
36 char *numerus_int_with_twelfth_to_roman(long int_part, short twelfths,
37  int *errcode);
38 
39 
40 /* Conversion function from roman numeral to value */
41 double numerus_roman_to_double(char *roman, int *errcode);
42 long numerus_roman_to_int(char *roman, int *errcode);
43 long numerus_roman_to_int_part_and_twelfths(char *roman, short *twelfths,
44  int *errcode);
45 
46 
47 /* Functions to manage twelfths */
48 double numerus_parts_to_double(long int_part, short twelfths);
49 long numerus_double_to_parts(double value, short *twelfths);
50 void numerus_shorten_and_same_sign_to_parts(long *int_part, short *twelfths);
51 
52 
53 /* Numeral analysis functions */
54 short numerus_is_zero(char *roman, int *errcode);
55 short numerus_is_long_numeral(char *roman, int *errcode);
56 short numerus_is_float_numeral(char *roman, int *errcode);
57 short numerus_sign(char *roman, int *errcode);
58 short numerus_count_roman_chars(char *roman, int *errcode);
59 short numerus_compare_value(char *roman_bigger, char *roman_smaller,
60  int *errcode);
61 
62 
63 /* Output formatting functions */
64 char *numerus_overline_long_numerals(char *roman, int *errcode);
65 char *numerus_create_pretty_value_as_double(double double_value);
66 char *numerus_create_pretty_value_as_parts(long int_part, short twelfths);
67 const char *numerus_explain_error(int error_code);
68 
69 
70 /* Command line interface */
71 int numerus_cli(int argc, char **args);
long numerus_double_to_parts(double value, short *twelfths)
Splits a double value to a pair of its integer part and a number of twelfths.
const char * numerus_explain_error(int error_code)
Returns a pointer to the human-friendly text description of any NUMERUS_ERROR_* error code...
const double NUMERUS_MIN_VALUE
The minimum value a roman numeral may have.
Definition: numerus_core.c:58
const char * NUMERUS_ZERO
The roman numeral of value 0 (zero).
Definition: numerus_core.c:84
short numerus_sign(char *roman, int *errcode)
Returns the sign of the roman numeral.
char * numerus_create_pretty_value_as_double(double double_value)
Allocates a string with a prettier representation of a double value of a roman numeral as integer par...
const long NUMERUS_MAX_LONG_NONFLOAT_VALUE
The maximum value a roman numeral with underscores without decimals may have.
Definition: numerus_core.c:30
long numerus_roman_to_int(char *roman, int *errcode)
Converts a roman numeral to its value floored and expressed as long integer.
Definition: numerus_core.c:508
Numerus error codes with their description.
const short NUMERUS_MAX_LENGTH
The maximum length a roman numeral string may have, including '\0'.
Definition: numerus_core.c:93
char * numerus_create_pretty_value_as_parts(long int_part, short twelfths)
Allocates a string with a prettier representation of a value as an integer and a number of twelfths...
char * numerus_int_to_roman(long int_value, int *errcode)
Converts a long integer value to a roman numeral with its value.
Definition: numerus_core.c:700
double numerus_roman_to_double(char *roman, int *errcode)
Converts a roman numeral to its value expressed as a double.
Definition: numerus_core.c:474
void numerus_shorten_and_same_sign_to_parts(long *int_part, short *twelfths)
Shortens the twelfths by adding the remainder to the int part so that they have the same sign...
const double NUMERUS_MAX_NONLONG_FLOAT_VALUE
The maximum value a roman numeral without underscores with decimals may have.
Definition: numerus_core.c:67
char * numerus_double_to_roman(double double_value, int *errcode)
Converts a double value to a roman numeral with its value.
Definition: numerus_core.c:726
const long NUMERUS_MIN_LONG_NONFLOAT_VALUE
The minimum value a roman numeral with underscores without decimals may have.
Definition: numerus_core.c:48
int numerus_error_code
The global error code variable to store any errors during conversions.
Definition: numerus_core.c:105
const double NUMERUS_MAX_VALUE
The maximum value a roman numeral may have.
Definition: numerus_core.c:40
char * numerus_int_with_twelfth_to_roman(long int_part, short twelfths, int *errcode)
Converts an integer value and a number of twelfths to a roman numeral with their sum as value...
Definition: numerus_core.c:757
char * numerus_overline_long_numerals(char *roman, int *errcode)
Allocates a string with a prettier representation of a long roman numeral with actual overlining...
long numerus_roman_to_int_part_and_twelfths(char *roman, short *twelfths, int *errcode)
Converts a roman numeral to its value expressed as pair of its integer part and number of twelfths...
Definition: numerus_core.c:545
const double NUMERUS_MIN_NONLONG_FLOAT_VALUE
The minimum value a roman numeral without underscores with decimals may have.
Definition: numerus_core.c:76
int numerus_cli(int argc, char **args)
Starts a command line interface that converts any typed value to a roman numeral or vice-versa...
Definition: numerus_cli.c:285
short numerus_compare_value(char *roman_bigger, char *roman_smaller, int *errcode)
Compares the values of two roman numerals, emulating the operator '>'.
short numerus_count_roman_chars(char *roman, int *errcode)
Returns the number of roman characters in the roman numeral.
short numerus_is_zero(char *roman, int *errcode)
Verifies if the roman numeral is of value 0 (zero).
Definition: numerus_utils.c:98
double numerus_parts_to_double(long int_part, short twelfths)
Converts a value expressed as sum of an integer part and a number of twelfths to a double...
short numerus_is_long_numeral(char *roman, int *errcode)
Verifies if the passed roman numeral is a long roman numeral (if contains a correct number of undersc...
short numerus_is_float_numeral(char *roman, int *errcode)
Verifies if the passed roman numeral is a float roman numeral (if contains decimal characters 'S' and...