You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Squirrel statement
(13725 > -2147483648)
produces false.
The culprit seems to be at line 199 of sqvm.cpp which reads:
_RET_SUCCEED(_integer(o1)-_integer(o2));
This code is trying to compare two integers, but the operation will cause the result to be an overflow -ve number and the result of the comparison will be false.
On line 201 the comparison of floats is correct:
_RET_SUCCEED((_float(o1)<_float(o2))?-1:1);
Line 199 should be modified to read:
_RET_SUCCEED((_integer(o1)<_integer(o2))?-1:(_integer(o1)==_integer(o2))?0:1);
Note that although I am using the max -ve 32-bit number in my example, the comparison will give the wrong result whenever you compare A to B where A - B > 2147483647.
Attila7 opened the ticket and wrote:
Reported version: trunk
Operating system: Windows
This issue was imported from FlySpray: https://bugs.openttd.org/task/3954
The text was updated successfully, but these errors were encountered: