compile-time function - (nf)
kolstad at parsec.UUCP
kolstad at parsec.UUCP
Sun Oct 16 12:51:30 AEST 1983
#R:hp-dcde:20000001:parsec:37300002:000:347
parsec!kolstad Oct 15 18:35:00 1983
Here's how I did LOG2:
#define LOG2(x) ((x)<=2?1: (x)<=4?2: (x)<=8?3: (x)<=16?4: \
(x)<=32?5: (x)<=64?6: (x)<=128?7: (x)<=256?8: (x)<=512?9: \
(x)<=1024?10: (x)<=2048?11:12 )
NB: The C compiler will evaluate this expression to a single constant
if it is supplied with a constant argument. The preprocessor
does NOT do the reduction.
More information about the Comp.lang.c
mailing list