Decimal to Binary Converter
Decimal numbers to binary, with two's complement.
This number base converter moves a number between any two bases from 2 to 36, and always shows binary, octal, decimal, and hexadecimal side by side. It works on integers of any length and on fractions.
Whole numbers of any length. Fractions (0.1) and a minus sign work too. Prefixes such as 0x, 0b, and 0o are accepted.
To read a number, each digit is multiplied by the base raised to its position, counting from 0 on the right:
7f (base 16) = 7 × 16¹ + 15 × 16⁰ = 127
To write a number in another base, it is divided by that base again and again; the remainders, read from last to first, are the digits. Fractions are multiplied by the base instead, and each whole part that comes out is the next digit. If a remainder repeats, the digits repeat forever, and the tool puts the repeating block in parentheses: 0.1 in decimal is 0.0(0011) in binary.
Integers use JavaScript BigInt, so a 100-digit number converts without rounding.
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 7 | 111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | a |
| 15 | 1111 | 17 | f |
| 16 | 10000 | 20 | 10 |
| 32 | 100000 | 40 | 20 |
| 64 | 1000000 | 100 | 40 |
| 100 | 1100100 | 144 | 64 |
| 127 | 1111111 | 177 | 7f |
| 255 | 11111111 | 377 | ff |
| 256 | 100000000 | 400 | 100 |
| 1024 | 10000000000 | 2000 | 400 |
Computers store everything in binary (base 2). Hexadecimal (base 16) is a compact way to write binary, since one hex digit is exactly four bits; it shows up in colors (#ff8800), memory addresses, and byte dumps. Octal (base 8) survives mainly in Unix file permissions such as 755. Base 36 uses all digits and letters and is sometimes used for short IDs.
Divide by 16 repeatedly and write the remainders from last to first, using a-f for 10 to 15. For example, 255 gives remainders 15 and 15, so it is ff.
Every base from 2 to 36. Bases above 10 use the letters a to z as digits.
Yes. Whole numbers are handled with BigInt, so there is no size limit beyond your browser's memory.
The way computers store negative integers: the bits of the positive value are inverted and 1 is added. In 8 bits, −1 is 11111111 and −128 is 10000000.
Often used together with the Number Base Converter.
Decimal numbers to binary, with two's complement.
Binary to reflected Gray code and back, step by step.
IPv4 to decimal, hex, octal, binary, and IPv4-mapped IPv6.