thp-zig/src/01_lexic/utils.zig

16 lines
347 B
Zig
Raw Normal View History

2024-11-16 21:12:15 +00:00
pub fn is_decimal_digit(c: u8) bool {
return '0' <= c and c <= '9';
}
2024-11-16 23:34:36 +00:00
pub fn is_octal_digit(c: u8) bool {
return '0' <= c and c <= '7';
}
pub fn is_binary_digit(c: u8) bool {
return c == '0' or c == '1';
}
2024-11-16 23:34:36 +00:00
pub fn is_hex_digit(c: u8) bool {
return ('0' <= c and c <= '9') or ('a' <= c and c <= 'f') or ('A' <= c and c <= 'F');
}