• 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: James Walker <email@hidden>
  • Date: Mon, 02 Nov 2009 12:06:14 -0800

Luke the Hiesterman wrote:

That said, the original question is a good one. Using x*x instead of pow(x,2)
would be quite a bit faster, so except for clarity reasons, there isn't a good
reason to use pow() in that case.

Would it really be that much faster? I don't know exactly how pow() is implemented, but I assume it's basically just a loop of multiplications, in which case it would basically be the same as x*x in this case, since it would exit after the first iteration....

Why would you assume that? Both parameters to pow are floating point, so in general I'd assume that logarithms and exponentials are involved. Maybe it has a special case for the exponent being an integer, but I wouldn't assume that.
--
James W. Walker, Innoventive Software LLC
<http://www.frameforge3d.com/>
_______________________________________________


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


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: Luke the Hiesterman <email@hidden>)

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