Code: Select all
var1 := "11111111111111111110"
var2 := "11111111111111111111"
test1 := (var1 = var2)
When run on v1.0.48.05, this code does
not compare "11111111111111111110" to "11111111111111111111". What it actually does is convert each string to a 64-bit number, and then compare the two numbers. Since these numbers are outside the supported range, the behaviour is effectively undefined. On the compiler used for the official v1.0.48.05 files, the out-of-range result of conversion for the two strings is different, so the comparison
appears to perform correctly. Try this instead, and you will see what it is actually comparing:
Code: Select all
var1 := "11111111111111111110"
var2 := "11111111111111111111"
MsgBox % var1+0 "`n" var2+0
If you take the v1.0.48.05 source code and compile it, without changes (aside from the necessary project settings to make it work), using Visual C++ 2019 (or most likely anything newer than 2003), both numbers produce 9223372036854775807. Compare:
For _atoi64 in Visual C++ 2019, Microsoft wrote:In the case of overflow with large positive integral values, _atoi64 returns I64_MAX and I64_MIN in the case of overflow with large negative integral values.
For _atoi64 in Visual C++ 2003, Microsoft wrote:The return value is undefined in case of overflow.
VC++2003 will produce an incorrect result in this case, while VC++2019 will happen to produce the correct result (but
how it arrives at that result is still no good):
Code: Select all
var1 := "11111111111111111110"
var2 := "11111111111111111111"
MsgBox % var1 = -7335632962598440506
MsgBox % var2 = -7335632962598440506
It believe this is caused by the way AHK (the one of the last 10 years or so?) handles variable types,
Which version of the last 10 years or so? AutoHotkey v2.0-a001 fixed some of these issues. That was in 2011.