• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: why use pow(x, 2)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why use pow(x, 2)?


  • Subject: Re: why use pow(x, 2)?
  • From: Luke the Hiesterman <email@hidden>
  • Date: Mon, 2 Nov 2009 11:38:23 -0800


On Nov 2, 2009, at 11:36 AM, Sherm Pendley wrote:

On Mon, Nov 2, 2009 at 2:25 PM, Ed Wynne <email@hidden> wrote:

That said, the original question is a good one. Using x*x instead of pow(x,2) would be quite a bit faster

Are you certain of that? With loop unrolling and inlined functions, it should result in identical code being produced by the compiler.

so except for clarity reasons, there isn't a
good reason to use pow() in that case.

Clarity should be the default, not the exception. Unless you've profiled your code and found the use of pow() to be a significant bottleneck, there's no good reason *not* to use it.


Completely agree. Never assume a performance problem until there is one.

Luke
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: why use pow(x, 2)?
      • From: Bob Smith <email@hidden>
    • Re: why use pow(x, 2)?
      • From: Ed Wynne <email@hidden>
References: 
 >why use pow(x, 2)? (From: Chunk 1978 <email@hidden>)
 >Re: why use pow(x, 2)? (From: Jens Alfke <email@hidden>)
 >Re: why use pow(x, 2)? (From: Chunk 1978 <email@hidden>)
 >Re: why use pow(x, 2)? (From: Ed Wynne <email@hidden>)
 >Re: why use pow(x, 2)? (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: why use pow(x, 2)?
  • Next by Date: Ruby Grammar for TDParseKit
  • Previous by thread: Re: why use pow(x, 2)?
  • Next by thread: Re: why use pow(x, 2)?
  • Index(es):
    • Date
    • Thread