jdoran 1 Posted September 19, 2013 Share Posted September 19, 2013 Math.If(Token.ReturnValue > 0.0, Size.Length / (Token.ReturnValue + (Token.ReturnValue == 0.0)), Infinity) determines the EntityMovementRate on a timepath. Can someone explain the "(Token.ReturnValue == 0.0)"? Token.ReturnValue is equal to the time the entity will take to traverse the path, so I can see the inverse relationship of time and speed, but I do no understand the purpose of that sub expression. If my thinking is correct, it will always evaluate to 0. If the IF statement somehow broke, only then would it evaluate to 1. Link to post Share on other sites
gdrake 1 Posted September 19, 2013 Share Posted September 19, 2013 I think that expression was simply originally coded that way to avoid any possibility of a Divide By Zero error, because the Math.If function in early Simio versions was evaluating every argument. However, I think now the Math.If only evaluates an argument in the expression if it has to, so possibly that TimePath expression could be simplified to remove that '+ (Token.ReturnValue==0.0)' stuff. Regardless, it is of course harmless coded as is. Link to post Share on other sites
jdoran 1 Posted September 19, 2013 Author Share Posted September 19, 2013 Thanks Glenn. It is certainly a more compact way of correcting for zero, than what I usually do. I will have to keep this trick in mind. Link to post Share on other sites
Recommended Posts