Binary to decimal and decimal to binary converter

Binary to decimal: add up the powers of 2 where there is a 1, so 1011 (binary) = 11 (decimal) and 1010 1010 (binary) = 170 (decimal). Type a binary number (spaces and 0b are fine) and the decimal value appears as you type, with hex and octal underneath; decimal to binary works in the same box.

Source: Wikipedia: Positional notation (base conversion, place values). Updated: .

My ToolboxYour inputs are saved in this browser only.

Result

Answer
1010 1010 (binary) = 170 (decimal)
Other bases
Hex: AA. Octal: 252. Bits needed: 8.
Working
  • Add up the place values (base 2 → decimal): 1·2⁷ + 0·2⁶ + 1·2⁵ + 0·2⁴ + 1·2³ + 0·2² + 1·2¹ + 0·2⁰ = 170
Conversion chart
BinaryDecimalHex
000
111
1022
1133
10044
10155
11066
11177
100088
100199
101010A
111115F
1 00001610
10 00003220
100 00006440
110 010010064
111 11111277F
1000 000012880
1100 0000192C0
1111 1111255FF
1 0000 0000256100
100 0000 00001024400
Values worth knowing
Valuebinarydecimal
One byte, all bits set1111 1111255
IPv4 first octet of 192.168.x.x1100 0000192
IPv4 second octet of 192.168.x.x1010 1000168
Subnet mask octet of a /211111 1000248
ASCII "A"100 000165
Sign bit of a byte1000 0000128
2 to the power 10100 0000 00001024
Binary uses only the digits 0 and 1; spaces, underscores and the prefix 0b are ignored. Results are exact for numbers of any length.

How it is calculated

How to convert binary to decimal

Each place is worth twice the one to its right: 1, 2, 4, 8, 16, 32, 64, 128 from the right. Add the places that hold a 1. 1011 is 8 + 2 + 1 = 11; the byte 1011 0110 is 128 + 32 + 16 + 4 + 2 = 182. The working under the answer lists the place values of your number.

The doubling method

For long numbers it is quicker to read left to right: start with 0, and for every bit double the running total and add the bit. For 1101: 0 → 1 → 3 → 6 → 13, so 1101 (binary) = 13 (decimal). It needs no table of powers, only the ability to double.

Decimal to binary

Divide by 2 repeatedly and read the remainders from the last to the first. For 13: 13 ÷ 2 = 6 r 1, 6 ÷ 2 = 3 r 0, 3 ÷ 2 = 1 r 1, 1 ÷ 2 = 0 r 1, giving 1101: 13 (decimal) = 1101 (binary). The number of bits grows slowly: 255 needs 8 bits (255 (decimal) = 1111 1111 (binary)), 256 needs 9 bits, 1,024 needs 11.

Bytes, IP addresses and masks

Counting on your fingers

Ten fingers, each up (1) or down (0), represent the numbers 0 to 1,023, because ten bits give 2¹⁰ = 1,024 values; with all fingers up the number is 1023. A byte read as a signed number (two’s complement) gives 1000 0000 = −128 rather than 128, a case handled by the number base converter. For hex see hex to decimal and for binary arithmetic the binary calculator.

Frequently asked questions

How do I convert binary to decimal?

Write the place values 1, 2, 4, 8 ... under the bits from the right and add those with a 1. For 1011: 8 + 2 + 1, so 1011 (binary) = 11 (decimal).

What is 1111 1111 in decimal?

1111 1111 (binary) = 255 (decimal). That is 2⁸ − 1, the largest value of one byte.

How do I convert decimal to binary?

Divide by 2 repeatedly and read the remainders from last to first. For 13: 13 (decimal) = 1101 (binary).

What is 10000000 in decimal?

1000 0000 (binary) = 128 (decimal), i.e. 2⁷. As a signed 8-bit number the same pattern means −128.

How many bits does a number need?

The largest n-bit number is 2ⁿ − 1, so 255 needs 8 bits (255 (decimal) = 1111 1111 (binary)) and 256 needs 9 (256 (decimal) = 1 0000 0000 (binary)).

Sources and legal basis

As of: · Editorial policy

Related tools