Beetwise

Convert binary to decimal

To convert a binary value into decimal, find each bit that has the value 1.

Each bit position holds a power of two.

Add the powers of two of all the bits that have the value 1.

Try it

The bits 100101100, which give 300. Select a bit to change it. Change the bit width or the signed mode to see the effect.

Name or expression
ID0
Binary
0b
Hex
0x
Decimal
ASCII
·,
Shift
Sign
Bits
Endian
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0

Worked example

Convert 100101100 into a decimal value:

  1. Number the bits from the right. The lowest bit is bit 0.
  2. Bit 2 has the value 1. Add 4.
  3. Bit 3 has the value 1. Add 8.
  4. Bit 5 has the value 1. Add 32.
  5. Bit 8 has the value 1. Add 256.
  6. The total is 300.

Where this is used

A logic analyser and a serial monitor often show a raw binary value.

A decimal form is easier to compare against a specification limit.

Points to note

  • Bit numbers start at 0, not 1.
  • The result depends on the signed mode. The bits 11111010 give 250 unsigned and -6 signed.
  • Zeros at the left do not change the result.

The full tool

The full editor holds many values at the same time. It also evaluates expressions across them, and it reads live values from a serial port.

Open the full editor

Questions

What is 100101100 in decimal?
The value is 300. The set bits are 8, 5, 3 and 2, which give 256 + 32 + 8 + 4.
Does the bit width change the result?
Not for an unsigned value. For a signed value the bit width sets which bit is the top bit.
What is 11111111 in decimal?
As an unsigned 8-bit value it is 255. As a signed 8-bit value it is -1.