Number Base Converter
Any base from 2 to 36, with binary, octal, decimal, and hex.
Type a decimal number and this decimal to binary converter writes it in base 2 straight away. It also shows octal and hex, and turns negative numbers into 8, 16, 32, or 64-bit two's complement.
Whole numbers of any length. Fractions (0.1) and a minus sign work too. Prefixes such as 0x, 0b, and 0o are accepted.
Divide the number by 2 and write down the remainder. Repeat with the quotient until it reaches 0. The remainders read from bottom to top are the binary digits.
156 ÷ 2 = 78 remainder 0 78 ÷ 2 = 39 remainder 0 39 ÷ 2 = 19 remainder 1 19 ÷ 2 = 9 remainder 1 9 ÷ 2 = 4 remainder 1 4 ÷ 2 = 2 remainder 0 2 ÷ 2 = 1 remainder 0 1 ÷ 2 = 0 remainder 1 156 = 10011100
To check, add the place values of the 1 bits: 128 + 16 + 8 + 4 = 156.
| Decimal | Binary | 8-bit |
|---|---|---|
| 0 | 0 | 00000000 |
| 1 | 1 | 00000001 |
| 2 | 10 | 00000010 |
| 3 | 11 | 00000011 |
| 4 | 100 | 00000100 |
| 5 | 101 | 00000101 |
| 8 | 1000 | 00001000 |
| 10 | 1010 | 00001010 |
| 16 | 10000 | 00010000 |
| 20 | 10100 | 00010100 |
| 32 | 100000 | 00100000 |
| 50 | 110010 | 00110010 |
| 64 | 1000000 | 01000000 |
| 100 | 1100100 | 01100100 |
| 128 | 10000000 | 10000000 |
| 255 | 11111111 | 11111111 |
Only fractions whose denominator is a power of 2 end in binary: 0.5, 0.25, 0.375. A tenth is 1/10, and 10 has a factor of 5, so its binary digits repeat forever. This is why 0.1 + 0.2 isn't exactly 0.3 in most programming languages: the computer stores the nearest binary value.
Divide by 2, note the remainder, and repeat with the quotient until you reach 0. Read the remainders from last to first.
1100100.
Press the swap button, or add up the place values (1, 2, 4, 8, 16, ...) of every 1 bit.
Usually in two's complement. Pick a width such as 8 bits, and −5 becomes 11111011.
Often used together with the Decimal to Binary Converter.
Any base from 2 to 36, with binary, octal, decimal, and hex.
Text to 8-bit binary and binary to text.
Binary to reflected Gray code and back, step by step.