Details
-
Bug
-
Resolution: Duplicate
-
P3: Somewhat important
-
None
-
5.13.2
-
None
-
Windows 10, CLion and/or QtCreator, x86 build, amd64 build
Description
The conversion of QString hex value to signed int 64 fails.
A possible workaround may be doing the conversion using toULongLong and afterwards cast to qint64.
void testToLongLong(qint64 value) { QString hexStrValue = QString::number(value, 16); bool ok; qint64 intValue; intValue = (qint64) hexStrValue.toULongLong(&ok, 16); Q_ASSERT_X(ok, "testToLongLong using cast", "returned not ok"); Q_ASSERT_X(intValue == value, "testToLongLong using cast", "values differ"); intValue = hexStrValue.toLongLong(&ok, 16); Q_ASSERT_X(ok, "testToLongLong using toLongLong", "returned not ok"); Q_ASSERT_X(intValue == value, "testToLongLong using toLongLong", "values differ"); } void testToLongLong() { testToLongLong(0x7FFFFFFFFFFFFFFF); // is working testToLongLong(0x8000000000000000); // doesn't work testToLongLong(0xAAAAAAAAAAAAAAAA); // doesn't work too }
Attachments
Issue Links
- relates to
-
QTBUG-53706 QString::number(-17, 16) should return "-11" not "0xffffffffffffffef"
-
- Closed
-