How Binary-to-Decimal Conversion Works
Binary is a positional numeral system with a base (radix) of 2. Each digit — called a bit — represents a power of 2 that increases from right to left, starting at 20. To convert a binary number to decimal, multiply each bit by its positional weight and sum the results.
For example, the binary value 1101 converts as follows: (1 x 23) + (1 x 22) + (0 x 21) + (1 x 20) = 8 + 4 + 0 + 1 = 13 in decimal.
The algorithm is straightforward: iterate over each bit from the most-significant position to the least-significant, accumulating the total. Because binary uses only two symbols (0 and 1), the multiplication step simplifies to either adding the weight or skipping it entirely. This makes binary ideal for digital circuits that distinguish between two voltage levels.
Bit Widths, Signed Integers, and Two's Complement
In practice, binary values are stored in fixed-width containers. The most common bit widths are:
- 8-bit (byte) — unsigned range 0 to 255; signed range -128 to 127
- 16-bit — unsigned 0 to 65,535; signed -32,768 to 32,767
- 32-bit — unsigned 0 to 4,294,967,295; signed roughly -2.1 billion to 2.1 billion
- 64-bit — unsigned 0 to 18.4 quintillion; used by modern CPUs and languages like Rust and Go for default integers
Signed integers use two's complement encoding. The most-significant bit (MSB) acts as the sign bit: 0 for positive, 1 for negative. To find the decimal value of a negative two's complement number, invert all bits, add 1, then negate the result. For instance, the 8-bit value 11111100 inverts to 00000011 (3), plus 1 gives 4, so the decimal value is -4.
Understanding bit widths matters when debugging overflow bugs, reading memory dumps, or interpreting register values. An unsigned interpretation of the same bit pattern yields a vastly different number than a signed interpretation once the MSB is set.
Where Binary Shows Up in the Real World
Binary isn't just a textbook concept — it appears in everyday developer work:
- Networking — IPv4 subnet masks like
255.255.255.0are11111111.11111111.11111111.00000000in binary. Understanding the boundary between network and host bits requires binary fluency. - File permissions — Unix chmod values such as
755map to three 3-bit groups:111 101 101(rwx r-x r-x). Each permission flag is a single bit. - Hardware registers — Microcontroller datasheets describe configuration registers bit by bit. Setting or clearing individual bits controls peripherals, interrupts, and clock sources.
- Bitwise operations — Flags, masks, and packed data structures in languages like C, Rust, and Go rely on AND, OR, XOR, and shift operators that work directly on binary representations.
- Color encoding — A 24-bit RGB color packs three 8-bit channels. The hex color
#FF8000is11111111 10000000 00000000in binary — useful when manipulating pixels at the bit level.
Related Conversion Tools
If you work with number systems regularly, these companion tools can help:
- Hex to Decimal Converter — convert hexadecimal values (base-16) to decimal, useful for reading memory addresses and color codes.
- Number Base Converter — convert between any bases from 2 to 36. Handles binary, octal, decimal, and hexadecimal in one place.
- Text to Binary Converter — encode plain text characters into their binary (ASCII/UTF-8) representations and vice versa.
All conversions run entirely in your browser — nothing is sent to a server, so your data stays private.