a style question

John E. Davis davis at pacific.mps.ohio-state.edu
Mon Oct 1 16:54:38 AEST 1990


In article <1990Sep30.172917.2951 at Neon.Stanford.EDU> kanamori at Neon.Stanford.EDU (Atsushi Kanamori) writes:
   >In article <1990Sep30.050655.13212 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
   >>In article <7341 at darkstar.ucsc.edu> aryeh at 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 at ohstpy
internet: davis at pacific.mps.ohio-state.edu



More information about the Comp.lang.c mailing list