Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15.0
-
None
Description
The following code fails with the message below:
qlonglong i64 = (1ll << 52) + 1;
double d = i64;
QVERIFY(d == i64);
QCOMPARE(qRound64(d), i64);
FAIL! Compared values are not the same
Actual (qRound64(d)): 4503599627370498
Expected (i64) : 4503599627370497
The integer value above has an exact representation within a double. It is the qRound64 method, which adds 0.5 to the integral value and thus introduces loss of precision in this step.
I didn't check if qRound is affected as well.