How to display int as hex?
-
I remember some time ago i was doing such thing in VS, but now i want to convert my local variable from decimal, to hex. AND without using QStrings.
int val = 15;
after some function should become:
int val = F;
It would be even nicer if somehow i would be capable convert not just to hex, but even convert that number in to memory address, like that:
int val = 0x0000000F;
But for the beginning simple inHex conversion will be suffice.
-
I remember some time ago i was doing such thing in VS, but now i want to convert my local variable from decimal, to hex. AND without using QStrings.
int val = 15;
after some function should become:
int val = F;
It would be even nicer if somehow i would be capable convert not just to hex, but even convert that number in to memory address, like that:
int val = 0x0000000F;
But for the beginning simple inHex conversion will be suffice.
-
Hi
Hex is a notion/presentation concept so im not sure what your goal is.
Anyway, if you dont want to use QString, there is also
std::hex -
Sorry, I don't understand what you want to do.
Note that:
int val = 15;
andint val = 0x000000F;
are binary identical in memory, butint val = F;
is syntactical wrong.Sorry, I don't understand what you want to do.
I can assign manually my int variables like "int val = 0x01;" but i want to do the same but with program functionality , so program can accept such value as a memory adress, which must be in hex.
Note that:
int val = 15;
andint val = 0x000000F;
are binary identical in memory, butint val = F;
is syntactical wrong.Well, QString::number(val, 16); returns int in hex and displays it for me in TextBrowser as just "f".