21 in binary
21 in binary, hexadecimal and octal, and how to work it out.
Converting 21 to binary by hand
Divide by 2 again and again, noting each remainder, until you reach 0. Then read the remainders from the bottom up: 10101.
| Divide | Answer | Remainder |
|---|---|---|
| 21 ÷ 2 | 10 | 1 |
| 10 ÷ 2 | 5 | 0 |
| 5 ÷ 2 | 2 | 1 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Checking it: each binary digit is worth twice the one to its right, so 10101 is 16 + 4 + 1 = 21.
Converting 21 to hexadecimal
The same way, dividing by 16, with remainders of 10 to 15 written as A to F. Reading up gives 15. Or split the binary into groups of four from the right (1 0101) and write each group as one hex digit.
| Divide | Answer | Remainder |
|---|---|---|
| 21 ÷ 16 | 1 | 5 |
| 1 ÷ 16 | 0 | 1 |
Whole numbers of any size. Prefixes like 0b, 0o and 0x, and spaces between digits, are ignored. Bases above 10 use the letters A to Z as digits.
Frequently asked questions
What is 21 in binary?
10101 (1 0101 in groups of four). It needs 5 bits.
What is 21 in hexadecimal?
15, often written 0x15.
What is 21 in octal?
25.
What is 10101 in decimal?
21: add the place values where there's a 1, 16 + 4 + 1 = 21.
16 in binary 17 in binary 18 in binary 19 in binary 20 in binary 22 in binary 23 in binary 24 in binary 25 in binary 26 in binary