Instance properties have absurd floating point numbers

Reproduction Steps

Set the property of any instance that includes a number (e.g. NumberValue.Value) and it will transform.

0.1 → 0.10000338

Expected Behavior

I expect that the number I input is precisely stored as a property in instances.

Actual Behavior


Issue Area: Engine
Issue Type: Other
Impact: Critical
Frequency: Constantly

This is because they’re stored as doubles. This happens to variables as well. This technically isn’t a bug but just how the computer processes numbers.


This is not a bug this is because of something known as floating point values these floating point values relate to something called IEEE-754 which is a standard for floating point values in the computer space. For example if you do 0.1 + 0.2 on a computer it will not give you 0.3 there will be tons of decimal places and an inaccurate number this is because computers don’t have amazing precision when it comes to floating point numbers. 64bit adds precision but it is not perfect I recommend watching a video on IEEE-754 to better understand floating point values.

I do not recall this happening before. It seems that this should NOT happen with decimals as large as 0.1 and should only happen with smaller decimals like 0.05

In this case i am not dealing w super small numbers and I’m instead dealing with rather large decimals like 0.1.

I will still mark your response as a solution but this needs to be evaluated.

You can just fix it by replacing:

until boulder.Transparency == 1


until boulder.Transparency >= 1

That’s not the point. This should not happen really. (Also that is not my code, it is from a different thread)

I didn’t explain it again because I thought you already knew, but this happens because of floating point errors. I’m also certain this was the case before too.

No, this definitely should happen - it would be kind of strange if it did anything else!

A consequence of floating point is that not all numbers can be represented with perfect precision. You can see this for yourself by using this floating point visualizer. If you want more of an explanation, this page does a good job of it without getting mired in the details.

1 Like

This should explain the reason why this happens pretty nicely.

1 Like