FMath::Pow with fractions returns 1 incorrectly

c++

FMath::Pow(1000, 1 / 3) is the cube root of 1000 which is 10, but returns 1 incorrectly.

I saw in a different report that 1 is returned by default for invalid inputs instead of NaN, but this is not an invalid input case, there should be a valid result.

Hello Earendel,

I believe the issue you’re experiencing is due to the syntax of the arguments you are providing.

This is the Syntax for FMath:Pow

FMath:Pow static float Pow
(
float A,
float B
)

When you divide a float by a float you want to be careful with how you are calling your order of operations. Here I’ve made the following changes to your arguments.

FMath::Pow(1000,(1.0f/3.0f));

This yields your desired result of 10.

Hope this helps!

Thank you, yes that works. I thought I had ruled that out as I tried 0.333f too so my only guess is that the editor wan’t using the updated code, my mistake. Hopefully this helps someone else too.