[Development] integer bug in Qt4.8.x
Darryl Miles
darryl-mailinglists at netbauds.net
Sat Mar 9 01:53:25 CET 2013
ARM uses are single-precision floating point, for qreal type at least.
This being 32bits and having an integer range of positive and negative
2^24+1.
I would expect JavaScript on ARM to be double-precision floating point,
since that is defined in the ECMA specification. This being 64bits and
has an integer range of positive and negative 2^53+1
Maybe this helps to explain the limit you are seeing.
2^24 = 16777216 so
2^24+1 = 16777217
after this point you lose precision of the least significant part, this
causes any assignment from an integer to start rounding to make it fit.
You should observe the need to increment the variable by 2 in order to
make it increase. Then by 4 to make it increase again..
So:
var num = 16777217.0;
num++; // this won't work value is still 16777217.0
num += 1.0; // nor this value is still 16777217.0
num += 2.0 // this will make it increase, as you overcame the bottom
bit loss of precision.
Are we sure that JavaScript on ARM using single-precision floats is
valid JavaScript maybe "QML" rewrites the programming rules.
Qt5 has fix the matter ?
HTH,
Darryl
More information about the Development
mailing list