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)
Usage examples (Cross-references)
- In
Io.c:1524:
char ch = input[pos];
if (IS_DIGIT(ch)) {
saw_digit = true;
need_exp_digit = false;- In
Io.c:2341:
// the token's shape.
static bool is_valid_number_char(char c, bool is_first_char, bool allow_decimal) {
if (IS_DIGIT(c))
return true;- In
Io.c:2584:
}
if (!StrIterPeek(&si, &c) || !IS_DIGIT(c)) {
StrIterMustPrev(&si);
break;- In
Io.c:2589:
}
while (StrIterPeek(&si, &c) && IS_DIGIT(c)) {
StrIterMustNext(&si);
}- In
Io.c:3402:
}
if (!StrIterPeek(&si, &c) || !IS_DIGIT(c)) {
StrIterMustPrev(&si);
break;- In
Io.c:3407:
}
while (StrIterPeek(&si, &c) && IS_DIGIT(c)) {
StrIterMustNext(&si);
}- In
Str.c:508:
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:1076:
bool have_digits = false;
while (pos < str->length && IS_DIGIT(str->data[pos])) {
result = result * 10.0 + (str->data[pos] - '0');
have_digits = true;- In
Str.c:1086:
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:1113:
// before that, and unbounded `exponent * 10 + digit` is signed
// overflow UB on inputs like "1e2147483648" (UBSan flags it).
while (pos < str->length && IS_DIGIT(str->data[pos])) {
if (exponent < 1024) {
exponent = exponent * 10 + (str->data[pos] - '0');- In
Types.h:580:
///
/// TAGS: Character, Validation, Hexadecimal
#define IS_XDIGIT(c) (IS_DIGIT(c) || IN_RANGE(c, 'a', 'f') || IN_RANGE(c, 'A', 'F'))
///
Last updated on