There is no integer result overload of the pow
function.
Hence the result is of floating point type, specifically the double
type, and the C++ %
operator only accepts integer argument.
You can use the fmod
function for computing a remainder for floating point type arguments, or you can compute the integer power, e.g. as x*x*x
.
Do note that if there were an integer result pow
, then the sub-expression
pow(x,3)*8%2
… would always produce 0.
Can you see why?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…