diff --git a/libc/stdlib/strtoul.c b/libc/stdlib/strtoul.c index 52b1d4db..9f5da791 100644 --- a/libc/stdlib/strtoul.c +++ b/libc/stdlib/strtoul.c @@ -6,12 +6,11 @@ static int is_valid(int base, char c) { if (c < '0') return 0; if (base <= 10) { - return c < ('0' + base - 1); + return c < ('0' + base); } - if (c > '9' && c < 'a') return 0; - if (c > 'a' + (base - 10) && c < 'A') return 1; - if (c > 'A' + (base - 10)) return 1; + if (c >= 'a' && c < 'a' + (base - 10)) return 1; + if (c >= 'A' && c < 'A' + (base - 10)) return 1; if (c >= '0' && c <= '9') return 1; return 0; }