From 06d3c41779712614701992f054998db6409a2683 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Fri, 11 Mar 2022 15:58:08 +0000 Subject: add TO_INFINITE_BASE flag * add to increment() one more argument (char* brand_new_digit) * add TO_INFINITE_BASE functionality Signed-off-by: Daniel Santos --- numericx.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/numericx.c b/numericx.c index 1b28dfe..2684ee4 100644 --- a/numericx.c +++ b/numericx.c @@ -79,16 +79,16 @@ numeral_infinity(char const* to_first, size_t cases) } void -increment(numeral_ptr* numeral, char* num_first, char* num_last) +increment(numeral_ptr* numeral, char* num_first, char* num_last, char* brand_new_digit) { bool cycled = false; if( numeral->symbol == num_last ) { if( numeral->next == NULL ) - numeral->next = new_digit(numeral, num_first); + numeral->next = new_digit(numeral, brand_new_digit); else - increment(numeral->next, num_first, num_last); + increment(numeral->next, num_first, num_last, brand_new_digit); cycled = true; } @@ -238,7 +238,7 @@ main(int argc, char* argv[]) } if( TO_FIRST_NUMBER_VOID ) - increment(result, to_first, to_last); + increment(result, to_first, to_last, to_first); } /* increments until it finishes */ @@ -249,12 +249,15 @@ main(int argc, char* argv[]) puts("----"); print_numeral(result); } - increment(result, to_first, to_last); + if( TO_INFINITE_BASE ) + increment(result, to_first, to_last, (to_first + 1)); + else + increment(result, to_first, to_last, to_first); if(DEBUG) print_numeral(counting); - increment(counting, from_first, from_last); + increment(counting, from_first, from_last, from_first); } if(DEBUG) puts("----"); -- cgit 1.4.1-2-gfad0