Hi all,
Just wanted to understand this strange behavior of Dynamo (Revit 2021, Dynamo 2.6.2)?
In the same list.
Noticed that rounding off to the nearest integer can give more accurate results. But what if rounding off is not an option?
Hi all,
Just wanted to understand this strange behavior of Dynamo (Revit 2021, Dynamo 2.6.2)?
In the same list.
Noticed that rounding off to the nearest integer can give more accurate results. But what if rounding off is not an option?
This is almost certainly a floating point error. Basically computers don’t deal with numbers the way we do, as they only have 0 and 1 to work with, so every number you see is an approximation, and that displayed value isn’t necessarily the same value which the computer is using. Sometimes these values surface to the UI, displaying 15.99999995 instead of 16. And sometimes they do not.
The fix for this is to round the value to the degree of precision which is needed for the project with the Math.Round node which has the input for a precision. A good rule of thumb is 6 digits, as we typically would use an alternate unit if we needed smaller values then that (ie: millimeters instead of meters).
Thanks. That explains it. Need to be careful when getting numbers in Dynamo from outside. I don’t think it could occur if you’re working with numbers inside the Dynamo environment only.
It can, but if the sequence of operations is the same for building both numbers it’s likely that the resulting value will be the same.
It’s important to note that this isn’t unique to the stuff you might build in Dynamo.
Google’s calculator function; Window’s calculator; In fact even Excel has seen these issues before.
Knowing what can trigger floating point issues and why it happens is good too know. My personal favorite explanation is this one: how floating point works - YouTube