Convert binary to decimal

Binary, octal, decimal, hex and bases 2 to 36. Runs on your device.

Binary numbers appear wherever a computer stores a yes-or-no choice, such as a flag in a settings byte, a permission mask or a network address split into bits. Each binary digit is worth a power of two, so 11111111 means one 128, one 64, one 32, one 16, one 8, one 4, one 2 and one 1, which adds up to 255. A byte is eight bits, so one byte holds the values 0 to 255, and a value above 255 needs a second byte. This page opens with 11111111 already typed and the From base set to binary, so the result shows 255 in decimal, with the octal and hexadecimal forms beside it. Type a longer binary number and the tool reads it in the same way, up to 1,024 digits. Spaces and underscores are ignored, so 1111 0000 reads as 240. A 0b prefix is accepted here because it matches the base. Any digit other than 0 or 1 is an error, because a number such as 12 is not binary.

How it works

  1. Type a number
  2. Pick the from and to bases
  3. Copy the result

How bases work

A base says how many digits a number system uses, and each position is worth a power of that base. Decimal is base 10, so 255 means two hundreds, five tens and five ones. Binary is base 2, which uses only 0 and 1, so the same value is written 11111111: one 128, one 64, one 32, one 16, one 8, one 4, one 2 and one 1, which add up to 255. Octal is base 8 and writes that value as 377. Hexadecimal is base 16. It uses 0 to 9 and then the letters A to F for 10 to 15, so 255 is FF. The tool also accepts any base from 2 to 36. Those bases use the letters A to Z for the digits 10 to 35, so Z is 35 and ZZ is 1295. Whatever the base, the value does not change: 255 is 11111111 in binary, 377 in octal, 255 in decimal and FF in hexadecimal, and the tool shows all four at once.

What you can type

Type digits from the From base. Letters A to Z are digits for bases above 10, and they are not case sensitive, so ff and FF are the same number. A prefix is accepted only when it matches the From base: 0b for binary, 0o for octal and 0x for hexadecimal. In decimal, 0x1F is an error, and the message says to set From base to Hexadecimal. Spaces and underscores are ignored, so 1111 0000 and 1111_0000 are both 240 in binary. In decimal only, commas written in thousands are ignored, so 1,000,000 is one million. A comma anywhere else is an error. A plus sign is allowed, and one minus sign makes the number negative. The tool converts whole numbers only: a decimal point or any digit after it is an error, because 1.5 would need rounding. Leading zeros do not change the value, so 00101 is 101 in binary.

Negative numbers and two's complement

A minus sign in front of the number means a negative number, and every result shows it in front of the digits: -255 is -11111111 in binary and -FF in hexadecimal. Computers store negative numbers in a fixed number of bits, usually two's complement. For a negative value the tool finds the smallest width of 8, 16, 32 or 64 bits that holds it and shows the bit pattern and its hexadecimal form. For -1 that is 11111111 in 8 bits, which is FF. For -128 it is 10000000, which is 80. For -129 it needs 16 bits: 1111111101111111, which is FF7F. A number below minus 2 to the power of 63 needs more than 64 bits, so the tool says the two's complement is not shown. The Magnitude bits tile counts the digits of the number without its sign, so -129 shows 8 there while its two's complement is 16 bits wide. The two's complement line is a view of a stored value, not a second conversion.

Long numbers and limits

The tool accepts up to 1,024 digits, not counting a prefix, a sign, spaces or underscores. Longer numbers get a message asking you to shorten them. All the arithmetic uses whole-number math, so nothing is rounded: 9007199254740993, which is 2 to the power of 53 plus 1, stays exact. A 1,024-digit hexadecimal number converts to a binary result of 4,096 digits, which wraps inside its row instead of widening the page. Digit grouping, the spaces or commas that make long values easier to read, is for display only. Copy always copies the digits without any spaces or commas, with the minus sign and the letter case you chose. Nothing you type is sent anywhere or stored. The only things saved on this device are your base choices, the grouping setting and the letter case.

Frequently asked questions

What is 11111111 in decimal?

11111111 is 255 in decimal. It is eight ones, so 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. That is the largest value a single byte holds.

Why does 12 give an error in binary?

Binary uses only the digits 0 and 1. The 2 is not a binary digit, so the message says Base 2 uses 0 and 1. Remove the 2 or pick a different From base.

Can I paste a binary number with spaces?

Yes. Spaces and underscores are ignored, so 1111 0000 and 1111_0000 both convert to 240. Copy always gives the digits with no spaces.

What is 255 in binary and hexadecimal?

255 is 11111111 in binary, 377 in octal and FF in hexadecimal. It is the largest value that fits in 8 bits, which is why a byte holds 0 to 255.

Why does 0x1F give an error when the From base is Decimal?

A number that starts with 0x is hexadecimal, and the x is not a decimal digit. Set From base to Hexadecimal and 0x1F becomes 31. The same rule applies to 0b for binary and 0o for octal.

Can it convert fractions such as 0.5?

No. This page converts whole numbers only. A decimal point is rejected, so type 0 or remove the digits after the point. Fractions in binary need a different method than whole numbers.

How are negative numbers shown?

The minus sign stays in front of each base: -128 is -10000000 in binary and -200 in octal. The two's complement line shows how -128 is stored in 8 bits: 10000000, which is 80 in hexadecimal.

How big a number can it take?

Up to 1,024 digits. Any value is exact, including 18446744073709551615, which is 2 to the power of 64 minus 1. In binary that is 64 ones, and in hexadecimal it is FFFFFFFFFFFFFFFF.

What are bases above 16 for?

Bases up to 36 use 0 to 9 and A to Z, so a long number needs fewer characters. ZZ is 1295 in decimal and Z is 35. Type the base in the Other field to use one.