Binary to decimal conversion
Consider a binary value with n binary digits, where ‘n’ is the position of a digit i.e. {0 to n} from LSB to MSB or Right to Left.
d_n, ..... d_4, d_3, d_2, d_1
The decimal value is equal to
Decimal = (d_n \times 2^n) + ... + (d_2 \times 2^2) + (d_1 \times 2^1) + (d_0 \times 2^0)
Example
Binary to Octal conversion
Each octal digit is in the range of [0-7]. So to represent any octal number three binary bits are sufficient. For example, see the below combinations
000 ---> 0
001 ---> 1
010 ---> 2
011 ---> 3
100 ---> 4
101 ---> 5
110 ---> 6
111 ---> 7
Now, let’s consider the following binary value <strong><strong>010100101111</strong></strong>
To find its equivalent octal value, make three binary bits as a group from right to left or (LSB to MSB) as shown below.
<strong>0<strong>10</strong></strong> <strong><strong>100</strong></strong> <strong><strong>101</strong></strong> <strong><strong>111</strong></strong>
Replace this with the combinations shown above to get the octal value.
Octal = 2457
Binary to Hexadecimal
Each hex digit is in the range of [0-F]. To represent a hex digit, 4 bits are required. For example, have a look at the below combinations.
0000 ---> 0
0001 ---> 1
0010 ---> 2
0011 ---> 3
0100 ---> 4
0101 ---> 5
0110 ---> 6
0111 ---> 7
1000 ---> 8
1001 ---> 9
1010 ---> A
1011 ---> B
1100 ---> C
1101 ---> D
1110 ---> E
1111 ---> F
Now, let’s consider the following binary value 010100101111
To find its equivalent hexadecimal value, make 4 binary bits as a group from right to left or (LSB to MSB) as shown below.
0101 0010 1111
Replace this with the combinations shown above to get a hexadecimal value.
Hex = 52F