IS_DIGIT
- Macro
- August 22, 2025
Table of Contents
IS_DIGIT
IS_DIGIT
Description
Checks if the given character c
is an ASCII digit.
Parameters
Name | Direction | Description |
---|---|---|
c | in | The character to check. |
Success
Returns true for 0-9, false otherwise.
Failure
Function cannot fail - always returns boolean result.
Usage example (Cross-references)
- In
Types.h:306
:
///
/// TAGS: Character, Validation, Hexadecimal
#define IS_XDIGIT(c) (IS_DIGIT(c) || IN_RANGE(c, 'a', 'f') || IN_RANGE(c, 'A', 'F'))
///
- In
Io.c:1356
:
static bool IsValidNumberChar(char c, bool is_first_char, bool allow_decimal) {
// Allow digits
if (IS_DIGIT(c))
return true;
- In
Io.c:1580
:
// Must have at least one digit in exponent
if (!IS_DIGIT(i[pos])) {
// Invalid exponent - back up to before the 'e'
pos--;
- In
Io.c:1587
:
// Continue with exponent digits
while (IS_DIGIT(i[pos]))
pos++;
break; // Stop after exponent
- In
Io.c:2479
:
// Must have at least one digit in exponent
if (!IS_DIGIT(i[pos])) {
// Invalid exponent - back up to before the 'e'
pos--;
- In
Io.c:2486
:
// Continue with exponent digits
while (IS_DIGIT(i[pos]))
pos++;
break; // Stop after exponent
- In
Str.c:273
:
// Helper function to convert character to digit
static inline bool char_to_digit(char c, u8* digit, u8 base) {
if (IS_DIGIT(c)) {
*digit = c - '0';
} else if (IN_RANGE(c, 'a', 'z')) {
- In
Str.c:791
:
// Parse integer part
while (pos < str->length && IS_DIGIT(str->data[pos])) {
result = result * 10.0 + (str->data[pos] - '0');
have_digits = true;
- In
Str.c:802
:
f64 scale = 0.1;
while (pos < str->length && IS_DIGIT(str->data[pos])) {
result += (str->data[pos] - '0') * scale;
scale *= 0.1;
- In
Str.c:827
:
bool have_exp_digits = false;
while (pos < str->length && IS_DIGIT(str->data[pos])) {
exponent = exponent * 10 + (str->data[pos] - '0');
have_exp_digits = true;