about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--numericx.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/numericx.c b/numericx.c
index ccf6f4f..41831e9 100644
--- a/numericx.c
+++ b/numericx.c
@@ -304,6 +304,39 @@ numeral_to_string(numeral_ptr* numeral, bool result_with_units_on_the_end)
 }
 
 /**
+ * @brief Check if number is void.
+ *
+ * Check if number is void by testing each digit to see if all of
+ * number's numerals correspond to void_numeral.
+ *
+ * @param number - Number string to be checked.
+ * @param void_numeral - Numeral that represents void.
+ *
+ * @result true if number is void.
+ * @result false if number is countable.
+ */
+static bool
+is_number_void(char* number, char* void_numeral, bool is_infinite)
+{
+	if( !is_infinite )
+	{
+		return ( (strlen(number) == 1) && (*number == *void_numeral) );
+	}
+	else
+	{
+		while( !(*number == '\0') )
+		{
+			if( *number != *void_numeral )
+				return false;
+
+			++number;
+		}
+
+		return true;
+	}
+}
+
+/**
  * @brief Translate string to a different numerical system.
  *
  * After definition of the 'from' numerical system proprieties and the
@@ -369,7 +402,7 @@ numericx_translate(char* from, bool from_units_on_the_end, bool from_first_numbe
 	{
 		if( from_first_number_void )
 		{
-			if( strlen(number) == 1 && *number == *from_first )
+			if( is_number_void(number, from_first, from_infinite_base) )
 			{
 				free_numeral(counting);
 				free_numeral(result);