Anyone knows if multiply operator is faster than using the Math.Pow method? Like:
n * n * n
vs
Math.Pow ( n, 3 )
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Basically, you should benchmark to see.
Educated Guesswork (unreliable):
In case it’s not optimized to the same thing by some compiler…
It’s very likely that
x * x * xis faster thanMath.Pow(x, 3)asMath.Powhas to deal with the problem in its general case, dealing with fractional powers and other issues, whilex * x * xwould just take a couple multiply instructions, so it’s very likely to be faster.