Clamp Randomly Slightly Alters Floating-Point Number
Found an issue here that took me a little to see exactly what was happening but I wanted to point it out with some screenshots. If you look at the two following images, you will notice that the value falls within the clamps min and max however slightly changes the value and this kind of thing scares me a little in cases where I need the number exactly as I expect it and I've also noticed a problem where values change ever so slightly within the engine and also if lets say I'm entering in 180 degrees into Yaw for a component on a given blueprint, sometimes I get 179.9999999998 and can't get it right on the dot. Someone mentioned this issue before to me and it is slightly annoying so I am assuming the two could be related. I'd really like to see this cleaned up and would be curious what is actually causing it. Another thing that happens is if I am typing 180 for that value or using the slider, it will make it negative sometimes so that's confusing. For the meantime, I just Floor'ed both values and then compared them so that's sufficient for the time being but hope this gets fixed in the near future. Thanks guys and take care.
Here are the screenshots from my Blueprint...
asked Sep 14 '14 at 10:09 PM in Bug Reports
Hey MC Stryker-
What you are seeing is the approximations that floating point numbers use to represent a finite number. There are some cases where floating point numbers are unable to represent specific values (such as .1 or .01). When working with floating point numbers it is usually best to use either 'greater than' or 'less than' rather than attempting to use 'equal to'. If you do need to compare to an exact number you may want to include a floor node (which will truncate the value) and then use an int instead of float.
answered Sep 18 '14 at 03:30 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here