How to implement (x POW y) in Java, where x and y are double?
•
Java
I want to calculate the power of X, y, x, y are double values Why did Java give me a compilation error? What is the best way to do this?
I am currently using the following methods:
x^y // attempt to calculate (x pow y)
thank you.
Solution
The simplest way to implement it is still:
Take the logarithm of X (base 10); Multiply it by Y and take the negative number of the result (base 10) to get x POW y
Simply calculate it, math pow(x,y);, As has been pointed out
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码