Skip to content

Instantly share code, notes, and snippets.

@gohan-kai
Created November 30, 2012 10:24
Show Gist options
  • Save gohan-kai/4175006 to your computer and use it in GitHub Desktop.
Save gohan-kai/4175006 to your computer and use it in GitHub Desktop.
C++ - Seeing Binary Hex Oct Decimal
//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