S
Shaobo Hou
Can anyone tell me why pow(-8.0, 1.0 / 3.0) (cubic root of -8) returns
nan (in linux) and negative infinity or something (in devcpp in
windows), instead of -2?
The problem seems to be that pow can't handle cubic root of negative
number, I mean, a calculator could do it or am I using the wrong
function here. My current solution is a hack which detects negative
input and handle it differently.
I suspect it is something to do with the fact the power is represented
as a floating point value.
nan (in linux) and negative infinity or something (in devcpp in
windows), instead of -2?
The problem seems to be that pow can't handle cubic root of negative
number, I mean, a calculator could do it or am I using the wrong
function here. My current solution is a hack which detects negative
input and handle it differently.
I suspect it is something to do with the fact the power is represented
as a floating point value.