Float pointing errors in calculation

You might be able to calculate it in C++ using doubles.

If you don’t wanna go into C++ you could use a Round node and compare the floating point end result with the input of the round using a Nearly Equal node with your own error tolerance. Hook the boolean outcome of the Nearly Equal node in a Select Float node. A of the select node should be the result of the Round and B should be the result of the Floor. I’m not a 100% sure this will work, let me know how it goes :slight_smile:

Hello,

i try to calculate the day of the week but i’ve noticed float pointing errors in the calculation.

7 = september in julian calendar

2.6*7 = 18.2 -0.2 = 18

But in blueprint i get

2.6*7 = 18.199999 - 0.2 = 17.999998

So i never get the floor to work as expected.

Maybe someone of you got some advice for me.

FWIW, FDateTime has functionality to do this. I don’t know how much of it is exposed to Blueprints out-of-the-box, but you can always add a UFUNCTION to expose anything that may be missing.