Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
4.6.2
-
None
-
Linux theta 2.6.34-gentoo-r1 #1 SMP PREEMPT Mon Aug 9 16:13:00 EDT 2010 x86_64 Intel(R) Core(TM)2 Duo CPU T7700 @ 2.40GHz GenuineIntel GNU/Linux.
Qt-4.6.2 from ebuild.
KDE 4.4.5
Description
QString::toLongLong fails for certain values. I clearly haven't tested all values, but I have definitely been able to consistently have it fail for large 64-bit values with the sign bit set. For example the following program does not behave as expected:
#include <QString> int main() { // test converting from a valid qulonglong qulonglong x = 0x8000000000000000; QString s = QString("%1").arg(x, 0, 16); // output the test qDebug("ORIGINAL NUMBER = %llx", x); qDebug("ORIGINAL STRING = %s", qPrintable(s)); // try to convert back **this fails** bool ok; qulonglong ll = s.toLongLong(&ok, 16); qDebug("RESULT OK = %d", ok); qDebug("RESULT NUM = %llx", ll); }
The expected output would be:
ORIGINAL NUMBER = 8000000000000000 ORIGINAL STRING = 8000000000000000 RESULT OK = 1 RESULT NUM = 8000000000000000
But Instead I receive the following:
ORIGINAL NUMBER = 8000000000000000 ORIGINAL STRING = 8000000000000000 RESULT OK = 0 RESULT NUM = 0
Using different numbers which do not have the sign bit set appear to work correctly. I have also only tested this for base 16 conversions.