Path: utzoo!attcan!uunet!mcsun!hp4nl!philapd!ssp11!dolf From: dolf@idca.tds.PHILIPS.nl (Dolf Grunbauer) Newsgroups: comp.lang.c Subject: Re: bug me now / bug me later Message-ID: <789@ssp11.idca.tds.philips.nl> Date: 14 Jun 90 13:44:35 GMT References: <811@sagpd1.UUCP> <340021@hplvli.HP.COM> Organization: Philips Information Systems, Apeldoorn, The Netherlands Lines: 36 In article <340021@hplvli.HP.COM> boyne@hplvli.HP.COM (Art Boyne) writes: Lets say you have the following (you ADA people, please bear with me): <> <> #define SIZE 6 <> #define STEP 2 <> <>Which is better: <> <> a. for(i = SIZE; i != 0; i -= STEP) <>or <> b. for(i = SIZE; i > 0; i -= STEP) <> <>Where this makes a difference is suppose SIZE is changed to 7. <>'a' goes into an infinite loop, while 'b' stops. < 0; i -= STEP) How about: #if (SIZE % STEP) != 0 SIZE not multiple of STEP #endif As now the compiler complains at compile time or your code will run faster. The compiler gives the line number as the line will probably not be valid C. I am aware that this trick will not work when SIZE & STEP (or at least one of them) are variables rather than macro's. -- Dolf Grunbauer Tel: +31 55 433233 Internet dolf@idca.tds.philips.nl Philips Information Systems UUCP ...!mcsun!philapd!dolf Some kind of happiness is measured out in miles