Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news1.dtag.de!feedme.news.telefonica.de!telefonica.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Miles Bader Newsgroups: comp.lang.c++ Subject: Re: Writing efficient normal distribution function (for learning purposes). Date: Sun, 19 Feb 2012 10:32:27 +0900 Lines: 18 Message-ID: <87fwe71uc4.fsf@catnip.gol.com> References: <5969204.9.1329493277515.JavaMail.geo-discussion-forums@vbnd9> Mime-Version: 1.0 Content-Type: text/plain X-Trace: individual.net XsakD/L7Vi1/p4Xbgf1fEwQsPip8TSinj0v7XOkwo2Vd2+p57+ Cancel-Lock: sha1:TT3CNOCnI+JeGlxtxFnRulqWPzU= sha1:4a9vFxEyFtrt901yRNh2s4yY2q8= System-Type: x86_64-unknown-linux-gnu Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:14251 glen herrmannsfeldt writes: >> pow(x,2) should be replaced by x*x as mentioned by others, it is not >> given that the optimizer is smart enough to do that by itself. > > I have complained about this before. Fortran compilers have been > known to optimize x**2 for many many years. Being an operator, > instead of a function, makes it more obvious. > > In addition, there is no pow(double, int) which would help in > optimizing many other cases. All the C++ compilers I've used _do_ optimize "pow(x,2)" to "x*x"... Not very hard as optimizations go... -miles -- Saa, shall we dance? (from a dance-class advertisement)