Hi! I was wondering why it gives out 22.29999 automatically instead of 22.3 when I type in that number. But it is 22.3 in a FVector which is also a float number. I used UProperty(editanywhere) to edit in UE5.2
This is more of a display annoyance. For blueprint editor purposes it could be rounded to X fractions (by the user input value) but it doesn’t. It’s just bad UX but you can ignore it. You already mentioned float precision. In fact you should never do :
float A = 3.f;
float B = 3.f;
if (A == B) {
// DoStuff
}
because it might or might not work. It’s random. It even depends on hardware what the results will be. Float precision is a funny thing a value set to 23.0f might not be exactly that.
1 Like
UnrealMathUtility to the rescue in that case
FMath::IsNearlyEqual
pass in A, B & tolerance.
1 Like
Thank you!
1 Like
Thank you for the solution!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.