C IF statement efficiency...

ben ullrich ben at bosco.UUCP
Sat Aug 20 05:41:01 AEST 1988


In article <8808171400.AA05122 at ucbvax.Berkeley.EDU> U23405 at UICVM writes:
>I was wondering if, of the two following program fragments, which one would
>be compiled more efficiently by most C compilers:
>
>          if (big > small)             if (big > small)
>               return big;                  return big;
>          else                         return small;
>               return small;
>

how about
	return ((big > small) ? big : small)

i don't know how efficient this is, but it is certainly more succinct than
those suggested in the quoted text above.


...ben
--
ben ullrich						sybase, inc.
database administrator					6475 christie avenue
mis department						emeryville, ca  94608
{pyramid,pacbell,sun,mtxinu,capmkt}!sybase!ben		415 - 596 - 3654



More information about the Comp.lang.c mailing list