• 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: "Gary L. Wade" <email@hidden>
  • Date: Mon, 02 Nov 2009 12:08:58 -0700
  • Thread-topic: why use pow(x, 2)?

On 11/02/2009 12:37 PM, "Luke the Hiesterman" <email@hidden> wrote:

> 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....
>
> Luke

pow takes a double for the parameter, not an integer, so pow doesn't
necessarily perform a loop (it may effectively be a single machine
instruction).  Also, in early Rosetta releases of Mac OS X, we found that
doing pow(10,3) would produce 1000.00...01 rather than 1000, which was
definitely a bug, but it illustrates the difference.


_______________________________________________

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: 
 >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: Ruby Grammar for TDParseKit
  • Previous by thread: Re: why use pow(x, 2)?
  • Next by thread: [moderator] Re: why use pow(x, 2)?
  • Index(es):
    • Date
    • Thread