about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDaniel Santos <dacs.git@brilhante.top>2022-03-11 15:58:08 +0000
committerDaniel Santos <dacs.git@brilhante.top>2022-03-11 16:03:07 +0000
commit06d3c41779712614701992f054998db6409a2683 (patch)
tree028aa3086b890b39283bbad5e1246d5a62c81e0e
parentdf82e9e3eb4d62c85554e877213361c6d80243db (diff)
downloadnumericx-c-06d3c41779712614701992f054998db6409a2683.tar.gz
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 <dacs.git@brilhante.top>
-rw-r--r--numericx.c15
1 files 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("----");