Decimal and binary
Decimal (base 10) is the everyday system: each digit is worth a power of 10. Binary (base 2) is how hardware stores every number: each digit is a bit, worth a power of 2.
Used to write bit masks, subnet masks and permissions, and to see which bits of a number are set.
This page opens the base converter with decimal as the input; it shows binary, octal, decimal, hexadecimal and Base64 at once, accepts prefixes such as 0x, 0b and 0o, and works with numbers of any length (no 2^53 limit). It runs in your browser.
Decimal vs binary
| Decimal | binary | |
|---|---|---|
| Base | 10 | 2 |
| Digits | 0–9 | 0 1 |
| Prefix in code | — | 0b |
| 255 is written | 255 | 11111111 |
How to convert decimal to binary by hand
Divide by 2 again and again and write down the remainders; read them from the last to the first. For 156:
| Division | Quotient | Remainder |
|---|---|---|
| 156 ÷ 2 | 78 | 0 |
| 78 ÷ 2 | 39 | 0 |
| 39 ÷ 2 | 19 | 1 |
| 19 ÷ 2 | 9 | 1 |
| 9 ÷ 2 | 4 | 1 |
| 4 ÷ 2 | 2 | 0 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Read upwards: 156 = 10011100 in binary.
Decimal to binary table
Values computed by the converter itself:
| Decimal | Binary |
|---|---|
0 | 0 |
1 | 1 |
2 | 10 |
7 | 111 |
8 | 1000 |
10 | 1010 |
15 | 1111 |
16 | 10000 |
32 | 100000 |
64 | 1000000 |
100 | 1100100 |
127 | 1111111 |
255 | 11111111 |
256 | 100000000 |
1000 | 1111101000 |
1024 | 10000000000 |
4096 | 1000000000000 |
65535 | 1111111111111111 |
Decimal to binary in code
JavaScript
(156).toString(2); // '10011100'Python
format(156, "b") # '10011100'For integers beyond 2^53 in JavaScript, use BigInt: BigInt("0x…").toString(2).
Frequently asked questions
Does it handle very large numbers?
Yes. The converter uses arbitrary-precision integers (BigInt), so a 256-bit hash or a 100-digit number converts exactly; JavaScript Number would lose digits above 2^53.
Can I convert negative numbers or fractions?
Negative integers keep their sign (-255 → -FF); the tool does not write two’s complement or fractional digits. For a two’s complement byte, add 256 first (−1 → 255 → FF).
Why do programmers use hexadecimal instead of binary?
Because it is binary in short form: 4 bits per digit, 2 digits per byte, so 0xFF is easier to read than 11111111 and still maps bit for bit.