Binary Converter - Decimal, Hex & Octal
Math ToolsEnter a number and click Convert to instantly convert between different number bases.
Understanding Number Systems
Number Base Comparison
Different number bases are used in various fields of computing and mathematics. Each base has specific advantages.
| Base | Digits |
|---|---|
| Binary (Base 2) | 0, 1 |
| Quaternary (Base 4) | 0–3 |
| Octal (Base 8) | 0–7 |
| Decimal (Base 10) | 0–9 |
| Hexadecimal (Base 16) | 0–9, A–F |
How Base Conversion Works
To convert a number from one base to another, divide the number repeatedly by the target base and collect the remainders. For example, converting decimal 42 to binary: 42 ÷ 2 = 21 remainder 0, 21 ÷ 2 = 10 remainder 1, 10 ÷ 2 = 5 remainder 0, 5 ÷ 2 = 2 remainder 1, 2 ÷ 2 = 1 remainder 0, 1 ÷ 2 = 0 remainder 1. Reading the remainders bottom-up gives 101010.
Quick Tips for Programmers
- In most programming languages, prefix 0b denotes binary (0b1010), 0o denotes octal (0o12), and 0x denotes hexadecimal (0xFF).
- One hexadecimal digit represents exactly 4 binary digits (bits). For example, 0xF = 0b1111.
- CSS/HTML color codes use hex: #FF5733 means R=255, G=87, B=51.
Glossary
- Bit
- A bit (binary digit) is the smallest unit of data in computing. It can hold a value of either 0 or 1. Eight bits make one byte.
- Byte
- A byte consists of 8 bits and can represent values from 0 to 255 (or 0x00 to 0xFF in hexadecimal). It is the fundamental unit of data storage.
- Radix (Base)
- The radix, or base, of a number system determines how many unique digits are used. For example, base 10 uses digits 0–9, while base 16 uses 0–9 and A–F.
- Two's Complement
- Two's complement is the most common method for representing signed integers in binary. The most significant bit indicates the sign: 0 for positive, 1 for negative.
Frequently Asked Questions
- Q: Why do computers use binary?
- A: Computers use binary because digital circuits have two states: on (1) and off (0). This maps naturally to electrical signals being high or low voltage.
- Q: Why is hexadecimal popular in programming?
- A: Hexadecimal is compact (one hex digit = 4 bits) and maps neatly to binary. A byte (8 bits) is exactly 2 hex digits, making memory addresses and byte values easy to read.
- Q: What is the largest number I can convert?
- A: This tool handles JavaScript's safe integer range (up to 2^53 - 1, or 9,007,199,254,740,991). For most practical purposes, this is more than sufficient.