-
-
Save gohan-kai/4175006 to your computer and use it in GitHub Desktop.
C++ - Seeing Binary Hex Oct Decimal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//To print 'hex' and 'oct' one can simply use std::cout | |
int a = 10; | |
std::cout<< hex << a; | |
std::cout<< oct << a; | |
std::cout<< dec << a; | |
//To see the binary whats comes in handy is std::bitset | |
#include <iostream> | |
#include <bitset> | |
#define MAX_BIT 8 | |
using namespace std; | |
int main() | |
{ | |
char a = 'a'; | |
std::bitset<MAX_BIT> x(a); | |
std::cout<<x; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment