Binary-to-decimal conversion is fundamental in computing, electronics and networking. Understanding how computers represent numbers in base 2 is essential for any developer, whether for network masks, bitwise operations or understanding the internal workings of a processor.
A binary number is expressed in base 2: each digit (bit) is 0 or 1, and its actual value depends on its position. The rightmost bit is worth 2⁰ = 1, the next is worth 2¹ = 2, then 2² = 4, 2³ = 8, etc. To convert to decimal, multiply each bit by its position value and add up the results.
📐 Formula
📊 Reference table
| Binary | Decimal | Detailed calculation |
|---|---|---|
| 0001 | 1 | 1×2⁰ = 1 |
| 0010 | 2 | 1×2¹ = 2 |
| 0100 | 4 | 1×2² = 4 |
| 0111 | 7 | 1×2² + 1×2¹ + 1×2⁰ = 4+2+1 |
| 1000 | 8 | 1×2³ = 8 |
| 1010 | 10 | 1×2³ + 1×2¹ = 8+2 |
| 1111 | 15 | 8+4+2+1 |
| 10000000 | 128 | 1×2⁷ |
| 11111111 | 255 | 128+64+32+16+8+4+2+1 |