Path: csiph.com!usenet.pasdenom.info!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!137.226.75.22.MISMATCH!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Bill Davy" Newsgroups: comp.arch.embedded Subject: Re: Slightly OT: speed of operation on a PC Date: Tue, 4 Aug 2015 19:19:55 +0100 Lines: 33 Message-ID: References: X-Trace: individual.net fQyI+spY7UqZcN2ck7JySA9iU8tg8BHBj+G8AgJYYe8+YL9N/1 Cancel-Lock: sha1:yBspQZ82N4QiLP6I4hNl81Ydt+o= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Original Xref: csiph.com comp.arch.embedded:21630 "Tim Wescott" wrote in message news:juKdnf5uzZr0YF3InZ2dnUU7-YOdnZ2d@giganews.com... > Which do you think is quicker on a PC, with the latest gnu compiler: > > double a = something; > double b = something else; > > if (a >= 0.0 && b < 0.0) > >>> or << > > if (a * b <= 0) > > Thank you for your time. > > -- > > Tim Wescott > Wescott Design Services > http://www.wescottdesign.com if a==1 and b==0, first expression is false, second expression is true so they are not equivalent. Border conditions are such a bother. I could proivide a similar expresion which is even faster but laso not right (0, for example). Sometimes the use of the sgn() function is even quicker. Rules of optimsiation: 1) Never 2) Later 3) Measure