strange hexadecimal representation
-
Hi. I have a strange hexadecimal representation when I'm trying to display it to console:
... sout << endl << "Request: "; for (int i = 0; i < request.size(); i++) sout << " 0x" << QString::number(request[i], 16); sout << endl; ...
two last value are evaluating by code:
... uint16_t u16 = getU16(); package.append(char(u16)); package.append(char(u16 >> 8)); ...
Data of request in debugger:
Output:
Why not just a "0xd1" and "0xfb" ?
Why extra "ffffffffffffff" are displaying ?What I'm doing wrong?
Thanks! -
You can simply use
QByteArray::toHex()
.Regarding the extra fs - I don't know. Maybe it is a bug in Qt.
-
@r3d9u11 said in strange hexadecimal representation:
Why extra "ffffffffffffff" are displaying ?
I guess because it's signed and negative and its converted to long when it is passed to QString::number
-
@r3d9u11 said in strange hexadecimal representation:
Why extra "ffffffffffffff" are displaying ?
QString::number probably makes an implicit cast. However 16bytes seems unusual
-
@jsulm said in strange hexadecimal representation:
@r3d9u11 said in strange hexadecimal representation:
Why extra "ffffffffffffff" are displaying ?
I guess because it's signed and negative and its converted to long when it is passed to QString::number