In this number conversion tutorial we are learning to convert number between three commonly used number system, Binary, Octal and Hexadecimal.

In this tutorial we will see six examples:

1. Binary to Octal conversion

2. Octal to Binary conversion

3. Binary to Hexadecimal conversion

4. Hexadecimal to Binary conversion

5. Octal to Hexadecimal conversion

6. Hexadecimal to Octal conversion

Before we start lets talk a little about the number system that we are going to cover in this tutorial.

In decimal number system we use ten digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. Decimal implies base 10.

In Binary number system we use two digits 0 and 1. Binary implies base 2.

In Octal number system we use eight digits 0, 1, 2, 3, 4, 5, 6 and 7. Octal implies base 8.

In hexadecimal number system we use ten digits and six english alphabet letters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F.

10 is denoted as A

11 is denoted as B

12 is denoted as C

13 is denoted as D

14 is denoted as E

15 is denoted as F

Hexadecimal implies base 16.

Following is the conversion table that we will use as a reference to perform conversion operations.

DECIMAL |
BINARY |
OCTAL |
HEXADECIMAL |

0 | 0 | 0 | 0 |

1 | 1 | 1 | 1 |

2 | 10 | 2 | 2 |

3 | 11 | 3 | 3 |

4 | 100 | 4 | 4 |

5 | 101 | 5 | 5 |

6 | 110 | 6 | 6 |

7 | 111 | 7 | 7 |

8 | 1000 | 10 | 8 |

9 | 1001 | 11 | 9 |

10 | 1010 | 12 | A |

11 | 1011 | 13 | B |

12 | 1100 | 14 | C |

13 | 1101 | 15 | D |

14 | 1110 | 16 | E |

15 | 1111 | 17 | F |

To convert a binary number into octal we follow the given steps

1. Divide the binary digits into groups of 3 digits, starting from the right.

2. Convert each group of 3 binary digits into 1 octal digit.

Convert Binary number 100101_{2} into Octal form

```
Step 1. Make groups of 3 digits from right
100101
```_{2}
Groups: 100_{2} 101_{2}
Step 2. Convert each 3 digits group into 1 octal digit
101_{2} = 5_{8}
100_{2} = 4_{8}
so, 100101_{2} = 45_{8}

To convert an Octal number into Binary we follow the following steps

1. Convert each octal digits into 3 digits binary group

2. Combine the groups

Convert Octal number 45_{8} into Binary form

```
Step 1. Convert each octal digit into 3 digits binary group
45
```_{8}
Groups: 4_{8} 5_{8}
5_{8} = 101_{2}
4_{8} = 100_{2}
Step 2. Combine the groups
so, 45_{8} = 100101_{2}

To convert a binary number into hexadecimal we follow the given steps

1. Divide the binary digits into groups of 4 digits, starting from the right

2. Convert each group of 4 binary digits into 1 hexadecimal digit

Convert Binary number 10100101_{2} into Hexadecimal form

```
Step 1. Make groups of 4 digits from right
10100101
```_{2}
Groups: 1010_{2} 0101_{2}
0101_{2} = 5_{16}
1010_{2} = 4_{16}
Step 2. Combine the groups
so, 10100101_{2} = 45_{16}

To convert a hexadecimal number into binary we follow the given steps

1. Convert each hexadecimal digit into group of 4 digits binary

2. Combine the groups

Convert Hexadecimal number A5_{16} into Binary form

```
Step 1. Convert each hexadecimal digit into group of 4 digits binary
A5
```_{16}
Groups: A_{16} 5_{16}
5_{16} = 0101_{2}
A_{16} = 1010_{2}
Step 2. Combine the groups
so, A5_{16} = 10100101_{2}

To convert an octal number into hexadecimal we follow the given steps

1. Convert each octal digit into groups of 3 digits binary

2. Combine the groups from step 1

3. Divide the binary digits from step 2 into groups of 4 digits, starting from the right

4. Convert each group of 4 binary digits into 1 hexadecimal digit

Convert Octal number 25_{8} into Hexadecimal form

```
Step 1. Convert each octal digit into groups of 3 digits binary
25
```_{8}
Groups: 2_{8} 5_{8}
5_{8} = 101_{2}
2_{8} = 010_{2}
Step 2. Combine the groups
so, 25_{8} = 010101_{2}
Step 3. Divide the binary digits from step 2 into groups of 4 digits, starting from the right
Groups: 0001_{2} 0101_{2}
Step 4. Convert each group of 4 binary digits into 1 hexadecimal digit
0101_{2} = 5_{16}
0001_{2} = 1_{16}
so, 25_{8} = 15_{16}

To convert a hexadecimal number into octal we follow the given steps

1. Convert each hexadecimal digit into groups of 4 digits binary

2. Combine the groups from step 1

3. Divide the binary digits from step 2 into groups of 3 digits, starting from the right

4. Convert each group of 3 binary digits into 1 octal digit

Convert Hexadecimal number 15_{16} into Octal form

```
Step 1. Convert each hexadecimal digit into groups of 4 digits binary
15
```_{16}
Groups: 1_{16} 5_{16}
5_{16} = 0101_{2}
1_{16} = 0001_{2}
Step 2. Combine the groups
so, 15_{16} = 00010101_{2}
Step 3. Divide the binary digits from step 2 into groups of 3 digits, starting from the right
Groups: 000_{2} 010_{2} 101_{2}
Step 4. Convert each group of 4 binary digits into 1 hexadecimal digit
101_{2} = 5_{8}
010_{2} = 2_{8}
000_{2} = 0_{8}
so, 15_{16} = 025_{8} = 25_{8}

Recently Added

- jQuery - Event propagation jQuery
- jQuery - Event delegation jQuery
- jQuery - Handling Events jQuery
- jQuery - Wrap elements and Remove elements jQuery
- jQuery - Adding elements outside existing elements jQuery
- jQuery - Adding elements inside existing elements jQuery
- jQuery - Property method jQuery
- jQuery - Attribute method jQuery
- jQuery - Styling DOM jQuery
- jQuery - Chaining Methods jQuery