Binary to Decimal Converter
Converts binary to decimal and back, showing the bit weights that produce the answer.
Last updated
Your details
Result
- Binary (base 2)
- 11111111
- Decimal (base 10)
- 255
- Hexadecimal (base 16)
- FF
- Octal (base 8)
- 377
- Bits needed
- 8
2 hex digits
11111111 in base 2…
value = Σ digit × baseᵖᵒˢⁱᵗⁱᵒⁿ
8 digits, read right to left
Each position is worth 2 times the one to its right
Total in decimal: 255
255
Formula — written step by step
Binary 11111111…
value = Σ bit × 2ᵖᵒˢⁱᵗⁱᵒⁿ
Weights from the right: 1, 2, 4, 8, 16, 32, 64, 128
Every bit is set, so all eight are added
128+64+32+16+8+4+2+1
11111111 = 255
Each bit is worth twice the one to its right. Eight bits set to one give 255, which is why a byte holds 256 distinct values counting zero — and why so many limits in computing are 255 or 256.
A worked example
Reading an IP address octet
- Binary
- 11000000
- Context
- the first octet of 192.168.0.1
- Bits set: positions 7 and 6
- 2⁷ = 128, 2⁶ = 64
- 128 + 64
- All other bits are zero
11000000 = 192
An IPv4 address is four bytes written as four decimal numbers, each 0 to 255. Subnet masks are far easier to understand in binary: 255.255.255.0 is twenty-four ones followed by eight zeros, which is what /24 means.
How to use this calculator
- Enter a binary value using only 0 and 1. A leading 0b is accepted and ignored.
- Read the decimal equivalent, with hexadecimal and octal alongside.
- Switch the mode to convert a decimal number into binary.
- The bits-needed row tells you how many binary digits the value occupies, which is the storage it requires.
Counting in twos
Binary is base two, using only the digits 0 and 1. Each position is worth twice the one to its right, so reading from the right the weights run 1, 2, 4, 8, 16, and so on. Converting to decimal means adding the weights of every position holding a 1.
That is the whole method. 1011 is 8 + 0 + 2 + 1 = 11. There is no trick beyond knowing the weights, which is why binary is the easiest base to convert by hand once the doubling sequence is familiar.
Why computers use it
A binary digit needs a component that distinguishes just two states — on or off, charged or not. That is enormously easier to build reliably than something distinguishing ten voltage levels, and far more tolerant of noise and manufacturing variation.
Everything else follows from that choice. Storage is measured in bits and bytes, capacities cluster around powers of two, and the awkward distinction between a kilobyte as 1000 bytes and a kibibyte as 1024 exists because ten is not a power of two.
Converting decimal to binary
The usual hand method is repeated division by two, recording each remainder and reading them upward at the end. Dividing 11 gives remainders 1, 1, 0, 1 — which read backwards is 1011.
A quicker mental method is subtracting the largest power of two that fits, and repeating. For 200: subtract 128, leaving 72; subtract 64, leaving 8; subtract 8, leaving 0. Bits at 128, 64 and 8 gives 11001000.
Bit weights and what they hold
| Bits | Highest value | Distinct values | Commonly |
|---|---|---|---|
| 1 | 1 | 2 | A flag |
| 4 | 15 | 16 | One hex digit — a nibble |
| 8 | 255 | 256 | A byte; one colour channel |
| 16 | 65,535 | 65,536 | A port number |
| 32 | 4,294,967,295 | 4.29 billion | An IPv4 address |
| 64 | 1.8 × 10¹⁹ | 1.8 × 10¹⁹ | A modern integer |
Each extra bit doubles the range. This is why 32-bit systems cap at about 4 GB of addressable memory, and why moving to 64 bits removed the ceiling rather than merely raising it.
Frequently asked questions
Why is 255 such a common limit?
Because it is the largest value eight bits can hold, and eight bits is one byte. Anything stored in a single byte caps at 255.
What is 0b?
A prefix marking a binary literal in many programming languages, in the same way 0x marks hexadecimal. It carries no value.
How do I convert decimal to binary by hand?
Divide repeatedly by two, keeping each remainder, then read the remainders in reverse. Or subtract the largest fitting power of two and repeat.
Why does binary use so many digits?
Because each digit carries the least possible information — one of two states. Eight binary digits carry the same value as two hexadecimal ones, which is why hex is preferred for writing.