You are not logged in.

mrdebug

Trainee

  • "mrdebug" is male
  • "mrdebug" started this thread

Posts: 90

Occupation: Developer

  • Send private message

1

Monday, February 14th 2011, 10:18am

QString and onversion in binary, decimal and hex

Dear users, I have a simple question for you on a problem that I don't understood.
See the explaination:

This code:

PHP Source code

1
2
char a95;
qDebug() << QString::number(a2)+ " "QString::number(a10)+ " "QString::number(a16);

return

PHP Source code

1
"1011111 95 5f"


but this

PHP Source code

1
2
a156;
qDebug() << QString::number(a2)+ " "QString::number(a10)+ " "QString::number(a16);

return

PHP Source code

1
"1111111111111111111111111111111111111111111111111111111110011100 -100 ffffffffffffff9c" 


Why QString::number(a, 10) doe not return "156" instead of "-100"?

2

Monday, February 14th 2011, 5:23pm

"signed char" have their values between -128 and +127. See wikipedia.
So 156 is really -100 inside a signed char, and that -100 value is converted to 64bits in your case.

Similar threads