Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Is using Math.pow faster than multiplying myself?

843789Oct 21 2009 — edited Oct 22 2009
Hi all,

Is it faster to use Math.pow to calculate a power than to, say, multiply it myself in a loop? How about if I'm just doing a square -- is it faster to use Math.pow(x,2) than x * x?

I noticed that the pow method in StrictMath has the keyword "native." Does this mean it's being done by the operating system? Does it mean it's being done directly in the hardware?

Thanks!

Tim
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 19 2009
Added on Oct 21 2009
6 comments
713 views