user command precision problem

user command precision problem

huajiang_h
Not applicable
378 Views
1 Reply
Message 1 of 2

user command precision problem

huajiang_h
Not applicable

[ FlexSim 22.2.0 ]

As shown in the model, after running the user command "aa" for many times, param (1) should be an integer multiple of 0.2, but it is not. Why1.png2.png函数精度问题_1.fsm

0 Likes
Accepted solutions (1)
379 Views
1 Reply
Reply (1)
Message 2 of 2

jason_lightfoot_adsk
Autodesk
Autodesk
Accepted solution

Doubles only store up to 16 decimal digits accurately although in practice the last digit often suffers rounding inaccuracy. The local variable window is showing sixteen digits, so you're seeing the affect of the inaccuracy and some rounding on that last digit which accumulates over many calculations and starts affecting the 15th and earlier digits. Most applications don't need that level of precision on large numbers, and those that do probably use a multiple precision arithmetic library to overcome the machine level limitations.

0 Likes