question

MSW avatar image
0 Likes"
MSW asked Felix Möhlmann answered

Math Calculate

I calculate total value from Globaltable, Below the picture, randnum=20.20 and total=20.20. Why it can't print "123"?Thank's.test.jpgTest.fsm

FlexSim 24.2.3
math
test.jpg (238.4 KiB)
test.fsm (29.6 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered

Due to floating point number inaccuracy the two variables aren't actually equal. If you want to check if two numbers (of which at least one is a double that is the result of some calculation), you should check if the difference between the two is smaller than some tiny value.

1742547487686.png


1742547487686.png (5.2 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.