#include "stdafx.h"
#include "stdio.h"
#include "conio.h"
#include "string.h"
#include "stdlib.h"
const char *bit_rep[16] =
{
"0000", "0001", "0010", "0011",
"0100", "0101", "0110", "0111",
"1000", "1001", "1010", "1011",
"1100", "1101", "1110", "1111"
};
int _tmain(int argc, _TCHAR* argv[])
{
unsigned long int num = 0x12345000;
int printnum = num;
int d = ((sizeof(num)*2)-1);
printf("Number in Hex : %x\n", num);
printf("Total Number of bits : %d\n",d);
printf("Number in bin = ");
for(d;d>0;d--)
{
int dm = d*4;
//printf("\n%d\n", (printnum >> dm) & 0x0F);
printf("%s", bit_rep[(printnum >> dm) & 0x0F]);
}
printf("%s", bit_rep[printnum & 0x0F]);
printf("\n");
getch();
return 0;
}
0 comments :
Post a Comment