Wondering what is the right way to represent x^(1/3)
? Here is my code and it returns right value 2
for 8^(1/3)
. Wondering if any other better methods?
int a = 8;
System.out.println(Math.pow(8, 1/3.0)); // returns 2
regards, Lin
Wondering what is the right way to represent x^(1/3)
? Here is my code and it returns right value 2
for 8^(1/3)
. Wondering if any other better methods?
int a = 8;
System.out.println(Math.pow(8, 1/3.0)); // returns 2
regards, Lin
There is a Math.cbrt
method for x1/3.
System.out.println(Math.cbrt(8));
See also: