CONVERTER

Binary to Decimal Converter (and Decimal to Binary)

Convert binary to decimal or decimal to binary, with hex and octal alongside, two’s complement for 8 to 64 bits, the working shown step by step, and a printable 0–255 chart.

Type in any field and the other three update. Spaces, underscores and the prefixes 0b, 0x and 0o are ignored. Fractions such as 101.101 work too; digits in brackets repeat forever, so 0.0(0011) means 0.000110011… in binary.

About this tool

This converter turns binary numbers into decimal and decimal numbers into binary, with hexadecimal and octal kept in step. All four fields are editable, the arithmetic uses JavaScript BigInt so a 200-digit binary number converts exactly, and a show-work panel writes out the same steps you would do on paper. It converts numbers. If you want to turn letters into their binary or hex byte codes (the word “Hi” into 01001000 01101001), use the Text to Binary converter instead; it encodes text as UTF-8 bytes, which is a different job.

How to use the binary to decimal converter

  1. Type or paste a binary number into the Binary field. Spaces and underscores between digit groups are fine, and so is a 0b prefix.
  2. Read the result in the Decimal field. Hex and octal update at the same time.
  3. To go from decimal to binary, type in the Decimal field instead. A leading minus sign gives a negative result such as -101010.
  4. Pick a width (8, 16, 32 or 64 bits) to see the two’s complement pattern, or to read your bits as a signed number.
  5. Open the show-work panel to copy the steps into homework or notes.

Positional notation: why binary works

Every digit in a number is worth its own value times a power of the base. In decimal the places are ones, tens, hundreds and so on (100, 101, 102). Binary uses the same idea with base 2, so the places from the right are worth 1, 2, 4, 8, 16, 32, 64, 128 and onward, doubling each time. Because each binary digit (a bit) is only ever 0 or 1, a place is either counted or skipped. To the right of the binary point the places keep halving: 1/2, 1/4, 1/8, which is why 101.101 is 4 + 1 + 0.5 + 0.125 = 5.625.

Worked example: 11010110 to decimal and back

The tool loads with 11010110. Number the places from the right starting at 0. The 1 bits sit in places 7, 6, 4, 2 and 1, so the value is 27 + 26 + 24 + 22 + 21 = 128 + 64 + 16 + 4 + 2 = 214. The same number is D6 in hex and 326 in octal.

To convert 214 from decimal to binary, divide by 2 again and again and write down each remainder:

StepQuotientRemainder
214 ÷ 21070
107 ÷ 2531
53 ÷ 2261
26 ÷ 2130
13 ÷ 261
6 ÷ 230
3 ÷ 211
1 ÷ 201

Reading the remainders from the bottom row up gives 11010110, the number we started with.

Two’s complement: how computers store negative numbers

A minus sign is fine on paper, but a register only holds a fixed number of bits. Most hardware stores signed integers in two’s complement: in an n-bit value the top bit is worth −2n−1 instead of +2n−1. To write −42 in 8 bits, start from 42 = 00101010, flip every bit to get 11010101, then add 1: 11010110. Notice that this is the same pattern as the default 11010110. Read as unsigned it means 214; read as signed 8-bit it means -42 (that is, −128 + 64 + 16 + 4 + 2). The bits don’t say which reading is meant; the program does. That is why the tool asks for a width, and why it reports “out of range” when 214 is encoded as signed 8-bit, whose largest value is 127.

Common mistakes

Use cases

The safe-integer limit comes from the MDN reference for Number.MAX_SAFE_INTEGER, and arbitrary-length arithmetic from BigInt.

Frequently asked questions

What is 1111 in decimal?

1111 in binary is 15 in decimal: 8 + 4 + 2 + 1. Four ones is the largest value four bits can hold, which is why one hex digit runs from 0 to F (15). Likewise 11111111 is 255, the largest unsigned byte, and a run of n ones always equals 2 to the power n, minus 1.

How do you write 100 in binary?

100 in decimal is 1100100 in binary. The largest power of 2 that fits is 64, leaving 36; then 32 leaves 4; then 4 leaves 0. So the 1 bits are in the 64, 32 and 4 places: 1100100. Padded to a full byte it is 01100100, and in hex it is 64.

How many bits do I need for a decimal number?

An unsigned whole number n greater than 0 needs as many bits as the length of its binary form, which is floor(log2 n) + 1. For example 255 needs 8 bits and 256 needs 9. A signed two's complement value needs one extra bit for the sign, so 8 bits only reach 127.

What is the binary for a negative number like -5?

With a minus sign it is simply -101. Inside a computer, -5 is usually stored in two's complement: in 8 bits that is 11111011 (flip 00000101 to 11111010, then add 1). In 16 bits the same value is 1111111111111011, because sign extension fills the new high bits with ones.

Why do programmers use hex instead of binary?

Hex is a shorthand for binary. Each hex digit stands for exactly four bits, so a byte that takes eight binary digits fits in two hex digits, and you can convert between them by looking at one group of four at a time. Long binary strings are hard to read and easy to miscount; hex keeps the bit layout visible.

What is octal used for?

Octal (base 8) groups bits in threes, so each octal digit covers three bits. Its best-known modern use is Unix file permissions: chmod 755 means read, write and execute for the owner (7 = 111) and read plus execute for group and others (5 = 101). Each octal digit converts to three bits on its own, with no carrying.