Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: towards a faster isdigit()
Message-ID: <1991May8.171838.24978@zoo.toronto.edu>
Date: Wed, 8 May 1991 17:18:38 GMT
References: <1991May8.030515.7004@twinsun.com> <716@taumet.com>
Organization: U of Toronto Zoology

In article <716@taumet.com> steve@taumet.com (Stephen Clamage) writes:
>>	#define isdigit(c) ((unsigned)((c)-'0') < 10)
>
>The macro you suggest requires a test and jump, and on some modern RISC
>machines the penalty is very high...

No, it requires a test and convert-test-value-to-data operation, which
on some RISC machines does not require a jump.  (I'll avoid putting in
a plug for my favorite one... :-))  Besides, the main use for predicates
like this is in driving conditional jumps, so in fact the conversion
is rarely needed and there is no added jump.
-- 
And the bean-counter replied,           | Henry Spencer @ U of Toronto Zoology
"beans are more important".             |  henry@zoo.toronto.edu  utzoo!henry
