Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!davis From: davis@pacific.mps.ohio-state.edu ("John E. Davis") Newsgroups: comp.lang.c Subject: Re: a style question Message-ID: Date: 1 Oct 90 06:54:38 GMT References: <7341@darkstar.ucsc.edu> <1990Sep30.050655.13212@zoo.toronto.edu> <1990Sep30.172917.2951@Neon.Stanford.EDU> Sender: news@pacific.mps.ohio-state.edu Reply-To: davis@pacific.mps.ohio-state.edu (John E. Davis) Organization: "Dept. of Physics, The Ohio State University" Lines: 34 In-reply-to: kanamori@Neon.Stanford.EDU's message of 30 Sep 90 17:29:17 GMT In article <1990Sep30.172917.2951@Neon.Stanford.EDU> kanamori@Neon.Stanford.EDU (Atsushi Kanamori) writes: >In article <1990Sep30.050655.13212@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes: >>In article <7341@darkstar.ucsc.edu> aryeh@cash.uucp (the over worked C something or another) writes: >>>Since I going to be doing my first team effort I want to know if this is bad >>>style: >>> for(x=0;x!=100;x++) ... >> >>Most people find it more readable with a bit of space and the statement >>on the next line: >> >> for (x = 0; x != 100; x++) >> ... >> >>The cautious would also recommend `x <= 100', but in this situation that >>is arguable. >I would say "x <= 100" is arguably bad. > "x < 100" is more like it. >More usefully, "<" seems to be a more common idiom than "!=" in upward counting >loops. So using "<" will probably shave a few microseconds off >the human reader's processing time. Which generates faster code? It seems to me that it is easier to tell if two values are unequal than to tell if one is greater than the other. I'd rather save the machine a few micro-seconds than myself since I only do the comparison once whereas the machine must do it many times. -- John bitnet: davis@ohstpy internet: davis@pacific.mps.ohio-state.edu