Hexadecimal representation in c

In hexadecimal number system we use 16 different digits so its base is 16. List of all hexadecimal digits:



Hexadecimal digit
Decimal equivalent
Binary equivalent
0
0
0000
1
1
0001
2
2
0010
3
3
0011
4
4
0100
5
5
0101
6
6
0110
7
7
0111
8
8
1000
9
9
1001
A
10
1010
B
11
1011
C
12
1100
D
13
1101
E
14
1110
F
15
1111



To convert the binary number into hexadecimal number:

Make the group of four binary digits from right to left and replace the four binary digits with the equivalent hexadecimal digit using above table.
For example:

Binary number = 11000111110101
Group of four digits from right side:



to make group of four digit of left most  digit 11 , add two zero at the left side i.e. 0011

Now put or replace with it the equivalent hexadecimal digit using above table




So, equivalent hexadecimal number will be 31F5







C tutorial home.
Post a Comment