I am new to Java. I am writing a small program to calculate the value of a number raised to a power, when I ran into a problem with negative numbers raised to a fractional exponent.
System.out.println(Math.pow(-8, 1/3f));
The output is NaN while I'm expecting -2?
What am I doing wrong? Are there any alternatives to calculate problems like this?
Any help appreciated.