Java – why math Pow (long, (1 / 3)) always returns 1?
•
Java
If the problem is power, how to write it correctly?
Solution
Try math Pow (long, 1D / 3)
By default, numeric text in Java is treated as int. therefore, 1 / 3 should be converted to 0 instead of 0.33333 Qualification using 1D or 1F or 1.0 will solve the problem
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
二维码