Float Precision Issue with Comparison in @editable Floats Summing to 100

Summary

When using multiple @editable floats that sum to 100 and some values have precision to the 4th or 5th decimal place, the equality check “if (Sum = 100.0):” fails. Although printing the sum shows it as 100.0, the comparison doesn’t work as expected. This appears to be caused by float precision errors.

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

  1. Define multiple @editable floats in your code with values that sum to 100.
  2. Set some of these floats to values with precision up to the 4th or 5th decimal place.
  3. Calculate the sum of these floats.
  4. Use an if statement to check if the sum is equal to 100.0 (e.g., “if (Sum = 100.0):” ).
  5. Print the sum for debugging purposes.

Expected Result

The condition “if (Sum = 100.0):” should evaluate to true if the sum of the floats is printed as exactly 100.0.

Observed Result

The condition “if (Sum = 100.0):” evaluates to false, even though printing the sum displays 100.0. This discrepancy suggests a float precision issue during the comparison.

Platform(s)

I’ve only tested this on PC so far.

Sometimes when I added up a bunch of numbers that equaled 3.0 and put it in an Int function like Int[3.0000] it would round to 2 instead of 3. The solution to it not rounding up properly is adding a really small number to the value like Int[3.000+ 0.000001]