How this binary converter works
The converter holds one number and shows it in five ways. Type in the binary, decimal, hexadecimal or octal field, or pick any base from 2 to 36 for the custom field, and the other four update on every keystroke. Spaces, underscores and the code prefixes 0b, 0o and 0x are accepted, and a character that is not a digit in that base is highlighted instead of being silently dropped.
Below the result, the bit count, byte count and the smallest standard integer width that holds the number are shown. The working panel explains the conversion both ways. For a single direction with a full explanation, see binary to decimal or decimal to binary.
The base conversion formulas
Example: 2D in hexadecimal is 2 Γ 16 + 13 Γ 1 = 45, and 45 in binary is 101101. Grouping 101101 into fours from the right gives 0010 1101, which reads back as 2 and D.
Worked examples
Example 1 β binary to decimal and hex
- Binary:
- 11010110
- Place values of the 1 bits: 128 + 64 + 16 + 4 + 2
- Add them: 214
- Group in fours: 1101 0110 β D 6
Answer: 214 decimal = D6 hex
Example 2 β a 64-bit value
- Hexadecimal:
- FFFFFFFFFFFFFFFF
- 16 hex digits Γ 4 bits: 64 ones in binary
- Largest 64-bit value: 2βΆβ΄ β 1
Decimal: 18,446,744,073,709,551,615
Ordinary floating-point arithmetic rounds this to 18,446,744,073,709,552,000. Integer arithmetic keeps every digit.
0 to 15 in binary, octal and hexadecimal
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 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 |
Largest unsigned value by bit width
| Width | Largest value (decimal) | Hexadecimal |
|---|---|---|
| 8 bits | 255 | FF |
| 16 bits | 65,535 | FFFF |
| 32 bits | 4,294,967,295 | FFFFFFFF |
| 53 bits (JavaScript safe integer) | 9,007,199,254,740,991 | 1FFFFFFFFFFFFF |
| 64 bits | 18,446,744,073,709,551,615 | FFFFFFFFFFFFFFFF |
Key facts
- Each binary place value is double the one to its right, so the bits of 101101 are worth 32, 16, 8, 4, 2 and 1, and the number equals 32 + 8 + 4 + 1 = 45.
- One hexadecimal digit always holds exactly four bits and one octal digit three, because 16 = 2β΄ and 8 = 2Β³; that is why 101101 converts to 2D by grouping alone.
- An n-bit unsigned integer holds 0 to 2βΏ β 1, so 8 bits reach 255 and 64 bits reach 18,446,744,073,709,551,615.
- Ordinary JavaScript numbers are exact only up to 9,007,199,254,740,991 (2β΅Β³ β 1), so a converter built on them rounds most 64-bit values.
Which base to use, and when
Binary
How hardware stores everything. Use it to read individual bits, flags and masks.
Hexadecimal
Compact binary: two hex digits make one byte. Used for memory addresses, colours such as #FF6600 and byte dumps.
Octal
Three bits per digit. It survives mainly in Unix file permissions, where 755 means rwxr-xr-x.
Exam questions
England's GCSE computer science content includes binary and hexadecimal and converting between them and decimal (source: DfE subject content).
Common conversion mistakes
- Grouping from the left. Split bits into fours or threes from the right, and pad the leftmost group with zeros.
- Reading remainders top-down. In repeated division the first remainder is the rightmost bit, not the leftmost.
- Starting place values at 2. The rightmost bit is worth 2β° = 1, not 2.
- Trusting floating point. Past 2β΅Β³ a spreadsheet or calculator may round the last digits; check large values with an exact tool.
Frequently Asked Questions
How do you convert binary to decimal?
Multiply each bit by its place value and add the results. Place values are powers of 2, starting at 1 on the right and doubling to the left: 1, 2, 4, 8, 16 and so on. For 101101, that is 32 + 8 + 4 + 1 = 45.
How do you convert decimal to binary?
Divide the number by 2 and write down the remainder, then divide the quotient by 2 again, and repeat until the quotient is 0. Reading the remainders from the last one to the first gives the binary number. 45 gives remainders 1, 0, 1, 1, 0, 1, so 45 is 101101.
How do you convert binary to hexadecimal?
Split the binary number into groups of four bits from the right, padding the leftmost group with zeros, then replace each group with one hex digit. 0010 1101 becomes 2 and D, so 101101 is 2D. This works because 16 is 2 to the power 4, so one hex digit always holds exactly four bits.
Why do other converters give wrong answers for large numbers?
Many converters use ordinary JavaScript numbers, which hold whole numbers exactly only up to 9,007,199,254,740,991 (2^53 β 1). Past that, the last digits are rounded. This converter uses arbitrary-precision BigInt arithmetic, so 64-bit values such as 18,446,744,073,709,551,615 and much larger numbers convert exactly.
What do the prefixes 0b, 0o and 0x mean?
They mark the base of a number written in code: 0b for binary, 0o for octal and 0x for hexadecimal, so 0b101101, 0o55 and 0x2D are all 45. You can paste a number with its prefix into the matching field and it is read correctly.
How are negative numbers converted?
Type a minus sign in front of the number. The converter keeps the sign, so β45 is β101101 in binary, which is the mathematical meaning of a negative binary number. Computers usually store negatives as a fixed-width two's complement bit pattern instead, which is a different representation of the same value.
Related calculators
Notes & Assumptions
- Whole numbers are converted exactly with arbitrary-precision integers, up to 4,096 characters of input.
- Negative numbers keep a minus sign. Fixed-width two's complement bit patterns are a different representation and are not produced here.
- Step-by-step working is shown for numbers up to 64 bits; the conversion itself is exact at any length.
This tool is for education and general calculation. Check results that feed into production code or hardware against your platform's own documentation.