Beetwise

Convert decimal to binary

To convert a decimal value into binary, divide the value by 2 and keep the remainder.

Repeat the division until the quotient is 0.

Read the remainders from the last one to the first one.

Try decimal to binary conversion in the bit editor

The value 300 in a 16-bit register. Edit the expression or select a bit to flip it.

15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
300
value · 16 bits · unsigned
binary
0b0000000100101100
Bit width

Decimal to binary conversion step by step

Convert 300 into binary: The steps follow the value above.

  1. 300 / 2 = 150 remainder 0
  2. 150 / 2 = 75 remainder 0
  3. 75 / 2 = 37 remainder 1
  4. 37 / 2 = 18 remainder 1
  5. 18 / 2 = 9 remainder 0
  6. 9 / 2 = 4 remainder 1
  7. 4 / 2 = 2 remainder 0
  8. 2 / 2 = 1 remainder 0
  9. 1 / 2 = 0 remainder 1
  10. Read the remainders from the last line up: 100101100

The value of each bit position

The value of each bit position
BitPower of twoValue
02^01
12^12
22^24
32^38
42^416
52^532
62^664
72^7128
82^8256
92^9512
102^101024
112^112048
122^124096
132^138192
142^1416384
152^1532768

Where decimal to binary conversion is used

A binary form shows which bits have the value 1. A decimal form hides them.

A register value is easier to check in binary, because each bit is a separate flag.

Decimal to binary conversion: points to note

  • The value 300 needs 9 bits. A register uses 8, 16, 32 or 64 bits, so the value goes into a 16-bit register.
  • Zeros at the left do not change the value. The bit width sets how many of them appear.
  • A negative decimal value needs a signed register. Use two’s complement for the negative form.

The full bit editor

The full editor holds many values, evaluates expressions across them, and reads live values from a serial port.

Open this value in the full editor

Questions about decimal to binary conversion

What is 300 in binary?
The value 300 is 100101100 in binary. In a 16-bit register it appears as 0000000100101100.
How many bits do I need?
Count the digits of the binary result. The value 300 gives 9 digits, so it needs at least 9 bits.
Can I convert a negative value?
Yes. Set the register to a signed mode. The negative value then uses two’s complement.