In my main model I am doing a methcall which will be called at time X, a variable keeps track of the latest X whenever this methcall is generated. When this method is then called because of the event, it compares the Eventcontroller's simulation time to the variable which contains the latest X. The method is not further executed (using return) when both times are not equal. This was done in order to only execute the latest methcall which was made and ignore the older ones.
When comparing the current time and the time from the variable, a weird situation occurs. I emulated the "glitch" in a simplistic test model which you can download below. Although in the test model no methods should be ignored, the "glitch" is the same. If you run the model you will encounter a debug stop such as the screenshot. savedTime (contains the latest X) is compared to currentTime, both are and should be equal if you look in the expressions frame on the bottom of the screenshot, but according to the result of the if-case window it sais that both times are not equal!
Why is this if-case not false?
Solved! Go to Solution.
I don't know the reason of such behaviour, maybe a rounding error or whatever. Time is the same as real data type and it's always dangerous to check whether real values are equal.
What you can do is using "about equal" operator this way:
if NOT (savedTime ~= currentTime) debug; else savedTime := totalTime &testMethod.methCall(timeInterval); end
It is indeed a rounding problem:
It is always a good idea to compare floating point values using ~= instead of =