Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!mcsun!hp4nl!charon!dik From: dik@cwi.nl (Dik T. Winter) Newsgroups: comp.lang.c Subject: Re: towards a faster isdigit() Message-ID: <3500@charon.cwi.nl> Date: 9 May 91 02:33:53 GMT References: <1991May8.030515.7004@twinsun.com> <20325@alice.att.com> Sender: news@cwi.nl Organization: CWI, Amsterdam Lines: 13 In article <20325@alice.att.com> ark@alice.UUCP () writes: > In article <1991May8.030515.7004@twinsun.com> eggert@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@cwi.nl