How to use
- Type a number. For binary to decimal, choose Binary (2) as the base of what you typed, then type something like 1010 or 0b1010.
- For decimal to binary, leave the base on Decimal (10) and type the number. The binary row is shown first.
- Every other base is shown below it, and a button copies each one. The page also tells you how many bits the number needs.
- Prefixes 0b, 0o and 0x, and underscores between digits such as 1111_0000, are understood.
Examples
255 (decimal)
→ 11111111 in binary, 377 in octal, ff in hexadecimalEight ones: the largest number that fits in one byte.
1010 (binary)
→ 10 in decimal1×8 + 0×4 + 1×2 + 0×1 = 10.
0b1111_0000
→ 240 in decimalThe 0b prefix and the underscore are accepted.
1024 (decimal)
→ 10000000000 in binary, 11 bitsA 1 followed by ten 0s, because 1024 is 2 to the power 10.
192 (decimal)
→ 11000000 in binaryOne byte of an IPv4 address such as 192.168.1.1. 168 is 10101000.
755 (octal)
→ 111101101 in binary, 493 in decimalThree octal digits, three bits each: 111 101 101, the Unix permissions rwxr-xr-x.
102 (binary)
→ Error: "2" is not a valid digit in base 2.Only 0 and 1 are digits here. The page names the digit instead of guessing.
How it works
This page is the number base converter with the binary row first. The conversion uses whole-number arithmetic of unlimited size, so a number with hundreds of digits is converted exactly. Digits that do not belong to the base you chose, such as a 2 in a binary number, are pointed out instead of being guessed.
How binary counts
Each place is worth twice the one to its right: 1, 2, 4, 8, 16, 32, 64, 128 and on. A digit is either 0 or 1, so a number is the sum of the place values that carry a 1. Eight places make a byte, which holds 0 to 255. Every place that is added doubles how many numbers fit, which is why sizes in computing run through 256, 1024, 65536.
Binary shortcuts
Binary, octal and hexadecimal are easy to turn into each other by grouping the bits. Three bits make one octal digit and four bits make one hex digit, so 1111 0000 is f0 and 111 101 101 is 755. To read a binary number quickly, split it into groups of four from the right, convert each group to one digit from 0 to f and join them.
| Binary | Decimal |
|---|---|
| 1 | 1 |
| 1010 | 10 |
| 11111111 | 255 |
| 10000000 | 128 |
| 10000000000 | 1024 |
What the page does not do
Fractions such as 0.5 are refused, because the page converts whole numbers only. It does not add or subtract binary numbers, it does not show bitwise operations such as AND and OR, and it does not turn text into binary. It converts one whole number between bases, and shows how many bits that takes.
Sources
Frequently asked questions
- How do I convert binary to decimal by hand?
- Write the place values 1, 2, 4, 8, 16 from the right, and add the ones where there is a 1. For 1101 that is 8 + 4 + 0 + 1 = 13.
- How do I convert decimal to binary by hand?
- Divide by 2 again and again and write down the remainders, then read them from last to first. For 13: 13 ÷ 2 = 6 r 1, 6 ÷ 2 = 3 r 0, 3 ÷ 2 = 1 r 1, 1 ÷ 2 = 0 r 1, read upward: 1101.
- How large a number can it convert?
- Numbers of any size are converted exactly, because the page uses whole-number arithmetic that does not round. Fractions are not converted.
- What is the custom base for?
- It shows the number in any base from 2 to 36, for example base 32 or base 36, which use the letters of the alphabet as extra digits.
- How many bits does a number need?
- The page counts the length of its binary form: 255 needs 8 bits, 256 needs 9, 65535 needs 16 and 65536 needs 17. Zero counts as 1 bit. Fixed-size types are wider than that, for example a number stored in 32 bits is padded with leading zeros.
- How big a number fits in 8, 16 and 32 bits?
- An n-bit unsigned number goes from 0 to 2 to the power n, minus 1: 255 for 8 bits, 65535 for 16 and 4294967295 for 32. Subtract one because counting starts at 0.
- Are leading zeros kept?
- No. The result has no leading zeros: 00001010 and 1010 both give 10 in decimal and 1010 in binary. If you need a fixed width such as 8 bits, add the zeros in front yourself.
- Why does a negative number come out with a minus sign?
- The page converts the number, not its storage. -10 is shown as -1010. Computers usually store negatives in two's complement, which needs a fixed width, so it is not shown here.
- Is anything sent to a server?
- No. The conversion happens in your browser.
Related tools
Version history
- 1.0.2 — Adds how binary counts, the shortcut between binary, octal and hex, how many bits fit in 8, 16 and 32, leading zeros, and what the page does not do, with more examples and questions.
- 1.0.1 — Clarifies the search title with the tool's main task and whether it is free or runs online.
- 1.0.0 — First release.