diff options
-rw-r--r-- | numericx.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/numericx.c b/numericx.c index 07dd870..1b28dfe 100644 --- a/numericx.c +++ b/numericx.c @@ -24,6 +24,14 @@ #define FROM_FIRST_NUMBER_VOID false #endif +#ifndef TO_INFINITE_BASE +#define TO_INFINITE_BASE false +#endif + +#ifndef FROM_INFINITE_BASE +#define FROM_INFINITE_BASE false +#endif + typedef struct NumeralPtr { char const* symbol; @@ -55,6 +63,21 @@ new_digit(numeral_ptr* last_numeral, char const* to_first) return starting_point; } +numeral_ptr* +numeral_infinity(char const* to_first, size_t cases) +{ + numeral_ptr* starting_case = new_digit(NULL, to_first); + numeral_ptr* other_case = starting_case; + + for(size_t i = 2; i <= cases; ++i) + { + other_case->next = new_digit(other_case, to_first); + other_case = other_case->next; + } + + return starting_case; +} + void increment(numeral_ptr* numeral, char* num_first, char* num_last) { @@ -191,8 +214,15 @@ main(int argc, char* argv[]) } /* initializing counting and result */ - numeral_ptr* counting = new_digit(NULL, from_first); - numeral_ptr* result = new_digit(NULL, to_first); + numeral_ptr* counting = NULL; + numeral_ptr* result = NULL; + + if( FROM_INFINITE_BASE ) + counting = numeral_infinity(from_first, strlen(number)); + else + counting = numeral_infinity(from_first, 1); + + result = numeral_infinity(to_first, 1); /* first number void */ if( !(FROM_FIRST_NUMBER_VOID && TO_FIRST_NUMBER_VOID) ) |