I've a number between 0 and 63, so max 6 bits.
Then I've to represent this number in hexadecimal.
How can I force the reresentation of my number in 8 bits so that if I have:
int x = 60;
cout << std::hex << x;
it prints 0x3C
?
I've a number between 0 and 63, so max 6 bits.
Then I've to represent this number in hexadecimal.
How can I force the reresentation of my number in 8 bits so that if I have:
int x = 60;
cout << std::hex << x;
it prints 0x3C
?
try this :
#include<iostream>
#include <iomanip>
using namespace std;
}
int main(){
int x = 60;
cout<<showbase; // show the 0x prefix
cout<<hex<<x;
return 0;
}
output :
0x3c