#endif
/**
- * Provide custom conversion scale limits based on selected type sizes.
+ * Provide custom conversion digit limits based on selected type sizes.
*
- * Utilize the f_type_number_* defines to determine the expected sizes to use for the scales.
+ * These designate the number of digits required to represent some number for some base unit.
*
* 64-bit is the designed default.
*/
#ifndef _di_f_type_number_64_t_
- #define f_conversion_scale_binary_unsigned 64
- #define f_conversion_scale_binary_signed 63
+ #define f_conversion_digits_binary_unsigned 64
+ #define f_conversion_digits_binary_signed 63
- #define f_conversion_scale_octal_unsigned 21
- #define f_conversion_scale_octal_signed 20
+ #define f_conversion_digits_octal_unsigned 22
+ #define f_conversion_digits_octal_signed 22
- #define f_conversion_scale_decimal_unsigned 19
- #define f_conversion_scale_decimal_signed 18
+ #define f_conversion_digits_decimal_unsigned 19
+ #define f_conversion_digits_decimal_signed 19
- #define f_conversion_scale_duodecimal_unsigned 17
- #define f_conversion_scale_duodecimal_signed 17
+ #define f_conversion_digits_duodecimal_unsigned 18
+ #define f_conversion_digits_duodecimal_signed 18
- #define f_conversion_scale_hexidecimal_unsigned 15
- #define f_conversion_scale_hexidecimal_signed 15
+ #define f_conversion_digits_hexidecimal_unsigned 16
+ #define f_conversion_digits_hexidecimal_signed 16
#endif // _di_f_type_number_64_t_
#ifdef _en_f_type_number_32_t_
- #define f_conversion_scale_binary_unsigned 32
- #define f_conversion_scale_binary_signed 31
+ #define f_conversion_digits_binary_unsigned 32
+ #define f_conversion_digits_binary_signed 31
- #define f_conversion_scale_octal_unsigned 10
- #define f_conversion_scale_octal_signed 10
+ #define f_conversion_digits_octal_unsigned 10
+ #define f_conversion_digits_octal_signed 10
- #define f_conversion_scale_decimal_unsigned 9
- #define f_conversion_scale_decimal_signed 9
+ #define f_conversion_digits_decimal_unsigned 9
+ #define f_conversion_digits_decimal_signed 9
- #define f_conversion_scale_duodecimal_unsigned 8
- #define f_conversion_scale_duodecimal_signed 8
+ #define f_conversion_digits_duodecimal_unsigned 8
+ #define f_conversion_digits_duodecimal_signed 8
- #define f_conversion_scale_hexidecimal_unsigned 7
- #define f_conversion_scale_hexidecimal_signed 7
+ #define f_conversion_digits_hexidecimal_unsigned 8
+ #define f_conversion_digits_hexidecimal_signed 8
#endif // _en_f_type_number_32_t_
#ifdef _en_f_type_number_128_t_
- #define f_conversion_scale_binary_unsigned 128
- #define f_conversion_scale_binary_signed 127
+ #define f_conversion_digits_binary_unsigned 128
+ #define f_conversion_digits_binary_signed 127
- #define f_conversion_scale_octal_unsigned 42
- #define f_conversion_scale_octal_signed 42
+ #define f_conversion_digits_octal_unsigned 43
+ #define f_conversion_digits_octal_signed 43
- #define f_conversion_scale_decimal_unsigned 38
- #define f_conversion_scale_decimal_signed 38
+ #define f_conversion_digits_decimal_unsigned 38
+ #define f_conversion_digits_decimal_signed 38
- #define f_conversion_scale_duodecimal_unsigned 35
- #define f_conversion_scale_duodecimal_signed 35
+ #define f_conversion_digits_duodecimal_unsigned 36
+ #define f_conversion_digits_duodecimal_signed 36
- #define f_conversion_scale_hexidecimal_unsigned 31
- #define f_conversion_scale_hexidecimal_signed 31
+ #define f_conversion_digits_hexidecimal_unsigned 32
+ #define f_conversion_digits_hexidecimal_signed 32
#endif // _en_f_type_number_128_t_
#ifdef __cplusplus
return F_data_not;
}
- uint8_t scale = 0;
+ uint8_t digits = 0;
f_number_unsigned_t digit = 0;
f_number_unsigned_t converted = 0;
for (f_string_length_t i = range.start; i <= range.stop; i++) {
if (f_conversion_character_to_binary(string[i], &digit) == F_none) {
- if (scale) {
- scale++;
+ if (digits) {
+ digits++;
if (negative) {
- if (scale > f_conversion_scale_binary_signed) {
+ if (digits > f_conversion_digits_binary_signed) {
return F_status_set_error(F_number_underflow);
}
converted -= digit;
}
else {
- if (scale > f_conversion_scale_binary_signed) {
+ if (digits > f_conversion_digits_binary_signed) {
return F_status_set_error(F_number_overflow);
}
}
}
else if (digit != 0) {
- scale = 1;
+ digits = 1;
if (negative) {
converted = 0 - digit;
return F_data_not;
}
- uint8_t scale = 0;
+ uint8_t digits = 0;
f_number_unsigned_t digit = 0;
f_number_unsigned_t converted = 0;
for (f_string_length_t i = range.start; i <= range.stop; i++) {
if (f_conversion_character_to_binary(string[i], &digit) == F_none) {
- if (scale) {
- scale++;
+ if (digits) {
+ digits++;
- if (scale > f_conversion_scale_binary_unsigned) {
+ if (digits > f_conversion_digits_binary_unsigned) {
return F_status_set_error(F_number_overflow);
}
converted += digit;
}
else if (digit != 0) {
- scale = 1;
+ digits = 1;
converted = digit;
}
}
return F_data_not;
}
- uint8_t scale = 0;
+ uint8_t digits = 0;
f_number_unsigned_t digit = 0;
f_number_unsigned_t converted = 0;
if (f_conversion_character_to_decimal(string[i], &digit) == F_none) {
- if (scale) {
- scale++;
+ if (digits) {
+ digits++;
if (negative) {
- if (scale > f_conversion_scale_decimal_signed) {
+ if (digits > f_conversion_digits_decimal_signed) {
if ((converted * 10) - digit < f_number_t_size_negative || (converted * 10) - digit > converted) {
return F_status_set_error(F_number_underflow);
}
converted -= digit;
}
else {
- if (scale > f_conversion_scale_decimal_signed) {
+ if (digits > f_conversion_digits_decimal_signed) {
if ((converted * 10) + digit > f_number_t_size_positive || (converted * 10) + digit < converted) {
return F_status_set_error(F_number_overflow);
}
}
}
else if (digit != 0) {
- scale = 1;
+ digits = 1;
if (negative) {
converted = 0 - digit;
return F_data_not;
}
- uint8_t scale = 0;
+ uint8_t digits = 0;
f_number_unsigned_t digit = 0;
f_number_unsigned_t converted = 0;
if (f_conversion_character_to_decimal(string[i], &digit) == F_none) {
- if (scale) {
- scale++;
+ if (digits) {
+ digits++;
- if (scale > f_conversion_scale_decimal_unsigned) {
+ if (digits > f_conversion_digits_decimal_unsigned) {
if ((converted * 10) + digit > f_number_t_size_unsigned || (converted * 10) + digit < converted) {
return F_status_set_error(F_number_overflow);
}
converted += digit;
}
else if (digit != 0) {
- scale = 1;
+ digits = 1;
converted = digit;
}
}
return F_data_not;
}
- uint8_t scale = 0;
+ uint8_t digits = 0;
f_number_unsigned_t digit = 0;
f_number_unsigned_t converted = 0;
if (f_conversion_character_to_duodecimal(string[i], &digit) == F_none) {
- if (scale) {
- scale++;
+ if (digits) {
+ digits++;
if (negative) {
- if (scale > f_conversion_scale_duodecimal_signed) {
+ if (digits > f_conversion_digits_duodecimal_signed) {
if ((converted * 12) - digit < f_number_t_size_negative || (converted * 12) - digit > converted) {
return F_status_set_error(F_number_underflow);
}
converted -= digit;
}
else {
- if (scale > f_conversion_scale_duodecimal_signed) {
+ if (digits > f_conversion_digits_duodecimal_signed) {
if ((converted * 12) + digit > f_number_t_size_positive || (converted * 12) + digit < converted) {
return F_status_set_error(F_number_overflow);
}
}
}
else if (digit != 0) {
- scale = 1;
+ digits = 1;
if (negative) {
converted = 0 - digit;
return F_data_not;
}
- uint8_t scale = 0;
+ uint8_t digits = 0;
f_number_unsigned_t digit = 0;
f_number_unsigned_t converted = 0;
if (f_conversion_character_to_duodecimal(string[i], &digit) == F_none) {
- if (scale) {
- scale++;
+ if (digits) {
+ digits++;
- if (scale > f_conversion_scale_duodecimal_unsigned) {
+ if (digits > f_conversion_digits_duodecimal_unsigned) {
if ((converted * 12) + digit > f_number_t_size_unsigned || (converted * 12) + digit < converted) {
return F_status_set_error(F_number_overflow);
}
converted += digit;
}
else if (digit != 0) {
- scale = 1;
+ digits = 1;
converted = digit;
}
}
return F_data_not;
}
- uint8_t scale = 0;
+ uint8_t digits = 0;
f_number_unsigned_t digit = 0;
f_number_unsigned_t converted = 0;
if (f_conversion_character_to_hexidecimal(string[i], &digit) == F_none) {
- if (scale) {
- scale++;
+ if (digits) {
+ digits++;
if (negative) {
- if (scale > f_conversion_scale_hexidecimal_signed) {
+ if (digits > f_conversion_digits_hexidecimal_signed) {
if ((converted << 4) - digit < f_number_t_size_negative || (converted << 4) - digit > converted) {
return F_status_set_error(F_number_underflow);
}
converted -= digit;
}
else {
- if (scale > f_conversion_scale_hexidecimal_signed) {
+ if (digits > f_conversion_digits_hexidecimal_signed) {
if ((converted << 4) + digit > f_number_t_size_positive || (converted << 4) + digit < converted) {
return F_status_set_error(F_number_overflow);
}
}
}
else if (digit != 0) {
- scale = 1;
+ digits = 1;
if (negative) {
converted = 0 - digit;
return F_data_not;
}
- uint8_t scale = 0;
+ uint8_t digits = 0;
f_number_unsigned_t digit = 0;
f_number_unsigned_t converted = 0;
if (f_conversion_character_to_hexidecimal(string[i], &digit) == F_none) {
- if (scale) {
- scale++;
+ if (digits) {
+ digits++;
- if (scale > f_conversion_scale_hexidecimal_unsigned) {
+ if (digits > f_conversion_digits_hexidecimal_unsigned) {
if ((converted << 4) + digit > f_number_t_size_unsigned || (converted << 4) + digit < converted) {
return F_status_set_error(F_number_overflow);
}
converted += digit;
}
else if (digit != 0) {
- scale = 1;
+ digits = 1;
converted = digit;
}
}
return F_data_not;
}
- uint8_t scale = 0;
+ uint8_t digits = 0;
f_number_unsigned_t digit = 0;
f_number_unsigned_t converted = 0;
if (f_conversion_character_to_octal(string[i], &digit) == F_none) {
- if (scale) {
- scale++;
+ if (digits) {
+ digits++;
if (negative) {
- if (scale > f_conversion_scale_octal_signed) {
+ if (digits > f_conversion_digits_octal_signed) {
if ((converted << 3) - digit < f_number_t_size_negative || (converted << 3) - digit > converted) {
return F_status_set_error(F_number_underflow);
}
converted -= digit;
}
else {
- if (scale > f_conversion_scale_octal_signed) {
+ if (digits > f_conversion_digits_octal_signed) {
if ((converted << 3) + digit > f_number_t_size_positive || (converted << 3) + digit < converted) {
return F_status_set_error(F_number_overflow);
}
}
}
else if (digit != 0) {
- scale = 1;
+ digits = 1;
if (negative) {
converted = 0 - digit;
return F_data_not;
}
- uint8_t scale = 0;
+ uint8_t digits = 0;
f_number_unsigned_t digit = 0;
f_number_unsigned_t converted = 0;
if (f_conversion_character_to_octal(string[i], &digit) == F_none) {
- if (scale) {
- scale++;
+ if (digits) {
+ digits++;
- if (scale > f_conversion_scale_octal_unsigned) {
+ if (digits > f_conversion_digits_octal_unsigned) {
if ((converted << 3) + digit > f_number_t_size_unsigned || (converted << 3) + digit < converted) {
return F_status_set_error(F_number_overflow);
}
converted += digit;
}
else if (digit != 0) {
- scale = 1;
+ digits = 1;
converted = digit;
}
}