1/3
is zero. Math.pow(a,0)
is 1
for all a != 0
, in particular for a = 27
.
The 1/3
division is performed between two integers using integer division, before the result is converted to a double
. You can get the result you are looking for by ensuring that the number is done using double division, e.g. 1.0/3
.