Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!linac!att!att!andante!alice!ark From: ark@alice.att.com (Andrew Koenig) Newsgroups: comp.lang.c Subject: Re: towards a faster isdigit() Message-ID: <20325@alice.att.com> Date: 8 May 91 16:18:49 GMT References: <1991May8.030515.7004@twinsun.com> Reply-To: ark@alice.UUCP () Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 18 In article <1991May8.030515.7004@twinsun.com> eggert@twinsun.com (Paul Eggert) writes: > Why not use the following implementation instead? > #define isdigit(c) ((unsigned)((c)-'0') < 10) > This needs just a subtraction followed by a comparison. It's faster on > all the systems I've tried it on, and is strictly conforming ANSI C. This is surely an implementation issue. 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) -- --Andrew Koenig ark@europa.att.com