Binary / Hex / Decimal Converter
Convert between binary, decimal, hexadecimal and octal number systems instantly.
Source: BBC Bitesize — Maths
By Konstantin Iakovlev · Founder, Calks.uk
Last updated: · Methodology reviewed for 2026
Decimal
255
Binary
11111111
Hexadecimal
FF
Octal
377
Disclaimer
This calculator is for guidance only. Double-check any result you rely on. Everything is calculated in your browser; nothing you enter is sent to our servers.
How It Works
Binary (base-2) uses only 0 and 1 to represent numbers. Each position represents a power of 2, starting from the right: 1, 2, 4, 8, 16 and so on. This converter translates between binary, decimal (base-10), octal (base-8) and hexadecimal (base-16) in any direction, which covers most of the number-base work in UK A-Level Computer Science.
At the lowest level all digital computing is binary, where 0 and 1 stand for off and on, false and true, low and high voltage, and a processor holds billions of transistors flipping between those two states. Storage sizes follow from the same idea, because they are powers of 2. A byte is 8 bits and holds 256 values, or 2⁸. A short is 16 bits and holds 65,536. An int is 32 bits and reaches 4.3 billion, while a long is 64 bits and reaches 18 quintillion.
Two methods convert a decimal number into binary. Repeated division by 2 records the remainders and reads them bottom-up, so 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 and 1 ÷ 2 = 0 remainder 1, which read upwards gives 101010. Subtraction is quicker once you know the powers, since you take the largest power of 2 that fits, mark a 1, and repeat, so 42 = 32+8+2 and again 101010.
Going the other way is positional arithmetic. Reading right to left, the column values double from 1 through 2, 4, 8, 16, 32 and 64 to 128, which are the powers 2⁰ up to 2⁷. So 10110 unpacks as (1×16) + (0×8) + (1×4) + (1×2) + (0×1) = 16+4+2 = 22, and 11111111 reads as 128+64+32+16+8+4+2+1 = 255, which is 377 in octal and FF in hexadecimal. Memorising the sequence 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 and 4096 makes all of this faster.
Binary addition needs only four rules, since 0+0=0, 0+1=1, 1+0=1 and 1+1=10 with a carry of 1. Adding 1011 and 0110 bit by bit with the carry gives 10001. Subtraction mirrors decimal but borrows 2 rather than 10. Negative values use two's complement, where you flip every bit and add 1, so an 8-bit −5 starts as 5 = 00000101, flips to 11111010 and becomes 11111011. The point of two's complement is that the same circuit can then handle both addition and subtraction.
Hexadecimal exists because long binary strings are hard for people to read. Base-16 uses the digits 0-9 followed by the letters A to F, where A stands for 10 and F for 15, with B, C, D and E filling the gap, and each hex digit maps onto exactly four bits, a nibble. Split 11010110 into 1101 and 0110 and it becomes D and 6, or 0xD6, which is 214 in decimal. That compactness is why hex shows up in HTML colours, where #FFFFFF is white and equals 16,777,215 in decimal, as well as in MAC addresses, memory addresses such as 0x7FFE and file dumps.
Example: Converting decimal 255
- Decimal 255 = Binary 11111111
- Decimal 255 = Octal 377
- Decimal 255 = Hexadecimal FF
- 11111111 in binary = 128+64+32+16+8+4+2+1 = 255
Source: BBC Bitesize — Maths
Frequently Asked Questions
- Can I convert a hexadecimal number back to decimal here?
- Yes, conversions run in any direction between binary, decimal, octal and hexadecimal. Hex uses the digits 0-9 followed by A to F, and each hex digit represents exactly four bits, so 0xD6 expands to 11010110 and equals 214 in decimal. Binary itself uses only 0 and 1, with each position standing for a power of two, running 1, 2, 4, 8, 16 and upwards from the right.
- How do I convert a decimal number into binary by hand?
- Divide repeatedly by 2 and read the remainders from the bottom up. For 42 that is 42 ÷ 2 = 21 remainder 0, then 21 ÷ 2 = 10 remainder 1, 10 ÷ 2 = 5 remainder 0, 5 ÷ 2 = 2 remainder 1, 2 ÷ 2 = 1 remainder 0 and 1 ÷ 2 = 0 remainder 1, giving 101010. Subtracting powers of 2 is faster once you know them, since 42 = 32+8+2.
- How are negative numbers stored in binary?
- Through two's complement, which flips every bit of the positive value and adds 1. To hold −5 in 8 bits, start with 5 as 00000101, flip it to 11111010, then add 1 to get 11111011. The reason for the extra step is practical, because with two's complement the same circuit performs addition and subtraction, so a processor needs no separate hardware for taking one number away from another.
- Why do programmers use hexadecimal instead of plain binary?
- Because it is far shorter to read while still mapping cleanly onto the underlying bits. Each hex digit covers exactly four binary digits, so 11010110 collapses to D6 rather than eight separate characters. That is why hex turns up in HTML colours, where #FFFFFF is white and equals 16,777,215, as well as in MAC addresses, memory addresses such as 0x7FFE and file dumps. Octal, base-8, plays a similar role, and 255 in octal is 377.