Binary, Decimal and Hexadecimal Number Systems: Methods for Converting Between Bases
Updated: November 6, 2026 · AracMerkezi
▶ Open Number Base Converter (Binary, Decimal, Hex)
In everyday life we write numbers in the decimal system: ten digits, 0 through 9. Computers work in the binary system, based on a signal being on or off, and programmers also use octal and hexadecimal systems alongside it. In this article you will get to know the four systems, learn two practical methods of converting between them by hand with examples, and see where mistakes are made.
Four systems, one logic
They all rest on the same rule: each digit of a number carries a value multiplied by a power of the base. In decimal, 345 = 3×10² + 4×10¹ + 5×10⁰. In binary the powers are powers of 2, and in hexadecimal powers of 16.
| System | Base | Digits used |
|---|---|---|
| Binary | 2 | 0, 1 |
| Octal | 8 | 0-7 |
| Decimal | 10 | 0-9 |
| Hexadecimal | 16 | 0-9 and A-F |
In hexadecimal, A=10, B=11, C=12, D=13, E=14, F=15. If it is not clear which base a number is written in, confusion follows: 101 is one hundred one in decimal, five in binary and 257 in hexadecimal. That is why software uses prefixes: 0b101, 0o755, 0x41.
Method 1: Binary to decimal
Each bit is multiplied by the power of 2 at its position and the results are added. Starting from the right, the positions run 1, 2, 4, 8, 16, 32.
Example: the number 101101. 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1 = 32 + 8 + 4 + 1 = 45.
Method 2: Decimal to binary (repeated division)
Divide the number by 2 and write down the remainder, divide the quotient again, stop when the quotient is 0, and read the remainders from last to first.
Example: 203. 203/2 = 101 remainder 1; 101/2 = 50 remainder 1; 50/2 = 25 remainder 0; 25/2 = 12 remainder 1; 12/2 = 6 remainder 0; 6/2 = 3 remainder 0; 3/2 = 1 remainder 1; 1/2 = 0 remainder 1. Read from last to first: 11001011. Check: 128+64+8+2+1 = 203.
Method 3: Grouping in fours for hexadecimal
Four bits correspond to exactly one hexadecimal digit. Split the binary number into groups of four starting from the right and convert each group.
Example: 110101111010. Groups: 1101 | 0111 | 1010. 1101 = 13 = D, 0111 = 7, 1010 = 10 = A. The result is D7A. Its decimal value is 3,450. In reverse, for 3F8 expand each digit into four bits: 0011 | 1111 | 1000. Its decimal value is 3×256 + 15×16 + 8 = 1,016.
In octal the same method works with groups of three: 755 = 111 | 101 | 101. This is why file permissions use octal numbers; for details see the Chmod Calculator.
Equivalents of small numbers
| Decimal | Binary | Hexadecimal |
|---|---|---|
| 0 | 0000 | 0 |
| 5 | 0101 | 5 |
| 10 | 1010 | A |
| 15 | 1111 | F |
| 16 | 10000 | 10 |
| 255 | 11111111 | FF |
Bit count and the largest value
With n bits you can represent numbers from 0 to 2ⁿ − 1. This is the source of overflow errors.
| Bits | Largest unsigned number | Example use |
|---|---|---|
| 8 | 255 | One color channel, one byte |
| 16 | 65,535 | Port numbers |
| 32 | 4,294,967,295 | A whole IPv4 address |
Text and color examples
The code of capital A is 65: 01000001 in binary, 41 in hexadecimal. Lowercase a is 97 (01100001). The Unicode and Binary Code Converter helps you see the byte equivalents of characters.
The color code #0B7A6B is three bytes: red 0B = 11, green 7A = 122, blue 6B = 107. For a detailed conversion you can use the HEX RGB guide and the Color Code Converter. The same logic appears in IP addresses: since 255 = 11111111, the last part of the subnet mask 255.255.255.192 is 11000000; you can see this in the IP address and CIDR guide.
Example: Verifying the number 172 in two ways
Finding a result by two independent routes is the most reliable way to catch an error. Take 172. By division: 172/2 = 86 r0; 86/2 = 43 r0; 43/2 = 21 r1; 21/2 = 10 r1; 10/2 = 5 r0; 5/2 = 2 r1; 2/2 = 1 r0; 1/2 = 0 r1. From last to first: 10101100. By the hexadecimal route: 172/16 = 10 remainder 12; 10 = A, 12 = C, so AC. If you expand AC into fours, A = 1010 and C = 1100, and you arrive at 10101100. If both routes give the same bits, the conversion is right. This number is the first part of the 172.16.0.0/12 private network range, which is why network engineers know its binary form by heart.
Which system is used where?
Decimal is preferred for values people will read (prices, quantities, age). Binary is useful when thinking about hardware and bit operations, for example to see which flag is on. Octal is the natural notation for groups of three bits such as Unix file permissions. Hexadecimal, because it lines up with byte boundaries, is common in color codes, memory addresses, debuggers and network devices. In the end, the right system depends on how the information is divided: hexadecimal suits pieces of 8, octal suits pieces of 3.
Why hexadecimal?
One byte (8 bits) is two hexadecimal digits: 11111111 = FF = 255. Long binary strings are hard to read and error-prone; hexadecimal writes the same information four times shorter. Memory addresses, error codes and colors are written in hexadecimal for this reason.
Common mistakes
- Writing the remainders in the order of division; the correct way is to read them from last to first.
- Starting the grouping from the left. Groups of four are built from the right; complete a short left group by padding it with 0s.
- Forgetting the base prefix:
10is a different number in each system (2 in binary, 8 in octal, 10 in decimal, 16 in hexadecimal). - Looking for a difference between lowercase and uppercase in hexadecimal.
ffandFFare the same value. - Writing the binary form of negative numbers with a sign. Computers mostly use the two's complement method; in 8 bits, −5 is stored as 11111011. This is outside the scope of the manual method here.
- Trying to convert fractional numbers with the same division method. The fractional part uses the multiply-by-2 method; 0.625 is 0.101 in binary.
Mini glossary
- Bit: A single binary digit.
- Nibble: 4 bits, one hexadecimal digit.
- Byte: 8 bits, two hexadecimal digits.
- Base: The number of digits in the system.
To check a conversion quickly, use the Number Base Converter, and for the byte equivalents of text use the Unicode and Binary Code Converter. Comparing the result you found by hand with the tool is the best way to cement the method.
Frequently asked questions
What is 255 in binary?
11111111; in hexadecimal it is FF. It is the largest unsigned number that fits in 8 bits.
What does A equal in hexadecimal?
10; A=10, B=11, C=12, D=13, E=14, F=15.
How do I convert a binary number to hexadecimal?
Split it into groups of four starting from the right and convert each group to one hexadecimal digit. For example, 1101 0111 1010 = D7A.
Tools mentioned in this guide
More guides
- How to Convert HEX to RGB Color Codes: Step-by-Step Examples – How to convert a HEX color code to RGB and back: hexadecimal basics, short and 8-digit HEX, darkening math and verified JavaScript and Python snippets.
- How to Choose a Color Palette for a Website: Building a Full Palette From One Color – How to choose a website color palette: build tints, accents and neutrals from one HEX color, with the 60-30-10 rule, contrast values and CSS variables.
- What Is Base32? Base32 vs Base64, Step-by-Step Encoding and TOTP Keys – How does Base32 work? Encode 'foo' to MZXW6=== bit by bit, compare sizes with Base64 and hex, and see why two-factor secrets are shown in Base32.
- What Is Color Contrast Ratio? A Step-by-Step WCAG AA and AAA Calculation with Example Colors – How is color contrast ratio calculated? WCAG AA and AAA thresholds (4.5:1, 3:1, 7:1), the luminance formula, worked color examples and tips.
- What Is the Difference Between PX, REM and EM? CSS Units, a Conversion Table and Which to Use When – What is the difference between px, rem and em in CSS, and which to use when? The px-to-rem formula, an em compounding example and a 16 px conversion table.
This article is for general information only and is not legal, financial or medical advice. We are not an official institution.