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.
- 300 / 2 = 150 remainder 0
- 150 / 2 = 75 remainder 0
- 75 / 2 = 37 remainder 1
- 37 / 2 = 18 remainder 1
- 18 / 2 = 9 remainder 0
- 9 / 2 = 4 remainder 1
- 4 / 2 = 2 remainder 0
- 2 / 2 = 1 remainder 0
- 1 / 2 = 0 remainder 1
- Read the remainders from the last line up: 100101100
The value of each bit position
| Bit | Power of two | Value |
|---|---|---|
| 0 | 2^0 | 1 |
| 1 | 2^1 | 2 |
| 2 | 2^2 | 4 |
| 3 | 2^3 | 8 |
| 4 | 2^4 | 16 |
| 5 | 2^5 | 32 |
| 6 | 2^6 | 64 |
| 7 | 2^7 | 128 |
| 8 | 2^8 | 256 |
| 9 | 2^9 | 512 |
| 10 | 2^10 | 1024 |
| 11 | 2^11 | 2048 |
| 12 | 2^12 | 4096 |
| 13 | 2^13 | 8192 |
| 14 | 2^14 | 16384 |
| 15 | 2^15 | 32768 |
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 editorQuestions 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.