# Binary, Octal, and Hexadecimal

In modern computing and digital electronics, the most commonly used bases are decimal (base 10), binary (base 2), octal (base 8), and hexadecimal (base 16). If we are converting between two bases other than decimal, we typically have to convert the number to base 10 first, and then convert that number to the second base. However, we can easily convert directly from binary to octal, and vice versa, and from binary to hexadecimal, and vice versa. This video gives a basic introduction to these conversions: https://youtu.be/5sS7w-CMHkU For another description, this one is more like a math lecture: https://youtu.be/2UwxdCLFW70 For further clarification, recall that the numbers 0 through 7 can be represented by up to three digits in base two. In base eight, these numbers are represented by a single digit.Base 2 (binary) number | Base 10 (decimal) equivalent | Base 8 (octal) number |
---|---|---|

000 | 0 | 0 |

001 | 1 | 1 |

010 | 2 | 2 |

011 | 3 | 3 |

100 | 4 | 4 |

101 | 5 | 5 |

110 | 6 | 6 |

111 | 7 | 7 |

Base 2 number | Base 10 equivalent | Base 8 number |
---|---|---|

1000 | 8 | 10 = 1 × 8 + 0 × 1 |

1001 | 9 | 11 = 1 × 8 + 1 × 1 |

1010 | 10 | 12 = 1 × 8 + 2 × 1 |

… | … | … |

111100 | 60 | 74 = 7 × 8 + 4 × 1 |

111101 | 61 | 75 = 7 × 8 + 5 × 1 |

111110 | 62 | 76 = 7 × 8 + 6 × 1 |

111111 | 63 | 77 = 7 × 8 + 7 × 1 |

_{8}= 1 × 8

^{2}+ 0 × 8

^{1}+ 0 × 8

^{0}= 1 × 64 + 0 × 8 + 0 × 1. In base 2, this would be 1000000

_{2}. Do you see a pattern here? For a single digit in base 8, we need up to three digits in base 2. For two digits in base 8, we need 4, 5, or 6 digits in base 2. For three digits in base 8, we need 7, 8, or 9 digits in base 2. For each additional digit in base 8, we need up to three spaces to represent it in base 2.

**Here’s a way to remember this: 2**A couple of examples would help here.

^{3}= 8, so we need three spaces.- Convert the number 6157
_{8}to base 2. We split each digit in base 8 to three digits in base 2, using the three digit base 2 equivalent, so 6_{8}= 110_{2}, 1_{8}= 001_{2}, etc. - Convert the number 10111011001010
_{2}to base 8. Split this number into sets of three,**starting with the right-most digit**, then convert each set of three to its equivalent in base 8.

^{4}= 16, so we need four digits. You may want to print out copies of these worksheets to help you with your conversions between binary and octal or hexadecimal: If you would like to quiz yourself on converting the numbers 0 through 255 to binary, octal, and hexadecimal (and between those bases), here’s a link to the representations of those numbers: Binary, Octal, and Hexadecimal Numbers.

## Licenses & Attributions

### CC licensed content, Original

- Mathematics for the Liberal Arts I.
**Provided by:**Extended Learning Institute of Northern Virginia Community College**Located at:**https://online.nvcc.edu/.**License:**CC BY: Attribution.

### CC licensed content, Shared previously

- Pre-Algebra 3 - Decimal, Binary, Octal & Hexadecimal.
**Authored by:**MyWhyU.**License:**All Rights Reserved.**License terms:**Standard YouTube License. - Binary, Hexadecimal, Octal conversion.
**Authored by:**Joey Lawrance.**License:**All Rights Reserved.**License terms:**Standard YouTube License.