Bug report: <= doesnt work

in my code the smaller or equal sign does not work on small fractions. my code compares <=, they are equal but the node pumps out false. how can that be?

  • Are you using code or blueprints?
  • If code, could you please provide the code that you are using so I can see how you are using the operator? If blueprint, please provide a screenshot of the blueprint in question.
  • Does this occur with whole numbers as well as precise decimals like you are using?

I’m using blueprints. I’ve never had this occur so I guess it only happens on precise decimals, or it was introduced in 11.2.

Hello,

After confirming that this was only happening with decimals, this leads me to believe that it is an issue with floats, which is not something that is an engine issue.

Have a look at this Answerhub post for suggestions on how to work around using floats: Why does <= only work as if it was <? - Programming & Scripting - Unreal Engine Forums

Let me know if you have any other questions regarding this issue.

Have a great day

You should never check floats for equality, well unless you want an infuriating time :slight_smile: Use a small tolerance value.

float a,b;

...
if (a == b) // BAD PUSSYCAT!

if (abs(a-b) < 0.001) // GOOD KITTY!

Thanks for the info but I don’t understand why this happens. If the engine rounds up the floats in any way because they are the same it should round them also to same values. If something is equal then it is equal no matter how you look at it. If the engine cant tell 2 numbers are equal how does it do any of the things it does…