Binary-Hex-Decimal Converter
Type in any box and the others follow. Any length is exact; spaces, commas, underscores and 0b/0o/0x prefixes are ignored, and a leading minus makes it negative.
Fixed-width form
Needs 8 bits · 1 byte
Width
- Bit pattern
- 1111 1111
- Hex
- 0xFF
- Read as unsigned
- 255
- Read as signed
- -1
Computers store negative integers in two's complement: invert every bit of the magnitude and add 1. The same bit pattern reads as a large unsigned number or as a negative signed one, which is why 0xFF is 255 unsigned but −1 as a signed byte.
How the conversion works
| 255 ÷ 2 | = 127 | remainder 1 |
| 127 ÷ 2 | = 63 | remainder 1 |
| 63 ÷ 2 | = 31 | remainder 1 |
| 31 ÷ 2 | = 15 | remainder 1 |
| 15 ÷ 2 | = 7 | remainder 1 |
| 7 ÷ 2 | = 3 | remainder 1 |
| 3 ÷ 2 | = 1 | remainder 1 |
| 1 ÷ 2 | = 0 | remainder 1 |
Divide by 2 until you reach 0, then read the remainders from the bottom up: 11111111. Dividing by 16 the same way gives hexadecimal, using A–F for remainders 10–15 (FF).
Convert numbers between binary, octal, decimal and hexadecimal: type in any of the four boxes and the others follow, with exact results at any length. The converter also shows the fixed-width bit pattern, how it reads as signed (two's complement) and unsigned, and the division steps behind the conversion.
Formula
Worked Example
Dividing 255 by 2 repeatedly leaves a remainder of 1 eight times, so it is 11111111 in binary; grouping the bits in fours gives F and F. In an 8-bit signed byte that same pattern means −1, because two's complement stores −1 as 2⁸ − 1 = 255.
Frequently Asked Questions
How do I convert binary to decimal?
Multiply each bit by its place value, a power of 2 counted from 0 on the right, and add them up. 1011 is 1×8 + 0×4 + 1×2 + 1×1 = 11.
Why is hexadecimal used in programming?
One hex digit stands for exactly four bits, so a byte is always two hex digits (00 to FF) and long bit patterns become short and readable. Colors (#FF8800), memory addresses and MAC addresses are written in hex for that reason.
How are negative numbers stored in binary?
Almost every computer uses two's complement: to negate a number, invert all its bits and add 1. In 8 bits, 5 is 00000101 and −5 is 11111011. The leftmost bit then acts as the sign, and an 8-bit byte holds −128 to 127.