Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!security!genrad!grkermit!mit-vax!eagle!mhuxi!houxm!ihnp4!inuxc!pur-ee!uiucdcs!parsec!kolstad From: kolstad@parsec.UUCP Newsgroups: net.lang.c Subject: Re: compile-time function - (nf) Message-ID: <3269@uiucdcs.UUCP> Date: Sat, 15-Oct-83 22:51:30 EDT Article-I.D.: uiucdcs.3269 Posted: Sat Oct 15 22:51:30 1983 Date-Received: Mon, 17-Oct-83 04:44:14 EDT Lines: 12 #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.