Here is a crazy string for numerical comparison in Qt (LTS 5.6.2) QML JavaScript implementation:
console.log("240000000000" == "3776798720"); console.log("240000000000" === "3776798720"); console.log("240000000000" === "3776798721");
And the result:
true true false
It looks like the string is interpreted as (u) int32 and the high byte is lost:
240000000000 == 0x37E11D6000 3776798720 == 0xE11D6000
This error also affects objects:
var g = {}; var h = "240000000000"; g[h] = h + "BUG"; console.log(JSON.stringify(g, null, 2)); console.log(g["3776798720"], g["240000000000"]);
Output:
qml: { "3776798720": "240000000000BUG" } qml: 240000000000BUG 240000000000BUG
As you can see, the key is damaged. The value can be obtained in two different lines.
Question
Is there any option to get a workaround with this without fixing Qt? Or at least an approximate location, where a problem in Qt might occur to improve itself?
ps Also here is QTBUG-56830 reported by my colleague.
source share