[Haskell-beginners] division / multiplication efficiency

Michael Orlitzky michael at orlitzky.com
Wed Nov 28 17:14:55 CET 2012


On 11/28/2012 08:02 AM, Christopher Howard wrote:
> Say I have functions like so:
> 
> code:
> --------
> circleRadians = 2 * pi
> 
> radius = (/ circleRadians)
> --------
> 
> My question: each time I call radius, will a division operation be
> performed? Is there anything to be gained, following the old adage that
> multiplication is more efficient than division in hardware, from
> something like:
> 

This doesn't answer your question, but is an interesting read:

http://stackoverflow.com/questions/12653787/what-optimizations-can-ghc-be-expected-to-perform-reliably

I've seen a lot of surprising stuff come out of the optimizer. If you
really want to know which is faster, try both ways.



More information about the Beginners mailing list