towards a faster isdigit()
Dik T. Winter
dik at cwi.nl
Thu May 9 12:33:53 AEST 1991
In article <20325 at alice.att.com> ark at alice.UUCP () writes:
> In article <1991May8.030515.7004 at twinsun.com> eggert at twinsun.com (Paul Eggert) writes:
> > #define isdigit(c) ((unsigned)((c)-'0') < 10)
> However, it does suggest an interesting puzzle: can you find a
> character set that meets the ANSI C constraints (in particular,
> the one that says that all digits are contiguous in the character
> set) for which this macro will not work? (Yes, I think there is one)
That is easy. If your character set uses '5'-s complement to represent
the digits it will fail. But the one I know that does that uses only 6 bits
for a char, so that violates another ANSI C constraint.
--
dik t. winter, cwi, amsterdam, nederland
dik at cwi.nl
More information about the Comp.lang.c
mailing list