Binary to Decimal Converter
Convert binary numbers to decimal with live step-by-step positional expansion, interactive 8-bit register toggle, two's complement, hexadecimal, and octal conversions.
Input & Mode Settings
Base 2 ↔ Base 10Interactive 8-Bit Register (Click any bit to toggle 0 / 1)
MSB (Bit 7) → LSB (Bit 0)Step-by-Step Positional Expansion Formula
= 128 + 64 + 0 + 16 + 0 + 4 + 2 + 0
= 214 (Base 10)
11010110 equals decimal 214. Under signed 8-bit two's complement, the leading bit (bit 7) represents −128 instead of +128, evaluating to −128 + 64 + 16 + 4 + 2 = −42.
| Bit Position | Bit Digit (bi) | Power of 2 (2i) | Positional Weight | Product Term | Subtotal |
|---|---|---|---|---|---|
| Bit 7 (MSB) | 1 | 27 | 128 | 128 | 128 |
| Bit 6 | 1 | 26 | 64 | 64 | 192 |
| Bit 5 | 0 | 25 | 32 | 0 | 192 |
| Bit 4 | 1 | 24 | 16 | 16 | 208 |
| Bit 3 | 0 | 23 | 8 | 0 | 208 |
| Bit 2 | 1 | 22 | 4 | 4 | 212 |
| Bit 1 | 1 | 21 | 2 | 2 | 214 |
| Bit 0 (LSB) | 0 | 20 | 1 | 0 | 214 |
Step-by-Step Binary to Decimal Conversion Guide
- List the Binary Digits from Left to Right: Write down your binary number. For example,
11010110. Identify the total number of digits ($n = 8$). - Assign Positional Exponents: Starting from the rightmost digit (Least Significant Bit, LSB), assign powers of 2 starting at 20, 21, 22, moving leftward up to 2n−1.
- Multiply Each Binary Digit by Its Weight: For each bit $b_i$, compute $b_i imes 2^i$. Bits equal to 0 produce a product of 0; bits equal to 1 keep the full power-of-two value.
- Sum the Products: Add all product terms together to obtain the final base-10 decimal number:
128 + 64 + 0 + 16 + 0 + 4 + 2 + 0 = 214.
Interpreting Results & Common Conversion Pitfalls
Converting between binary and decimal is fundamental in computer systems, networking, and digital logic. However, several subtle representation traps cause errors in programming and hardware analysis:
- Unsigned vs. Two's Complement Interpretation: A raw byte of binary digits like
11111111evaluates to 255 in unsigned integer mode, but evaluates to −1 in 8-bit signed two's complement. Always confirm whether the target system interprets the leading Most Significant Bit (MSB) as a sign bit or as positive magnitude. - Endianness Confusion: Big-endian order places the most significant byte first (left-to-right), whereas little-endian architectures (such as x86 and ARM in standard modes) store the least significant byte at the lowest memory address. Inverting byte order produces completely incorrect numerical values.
- Fractional Binary Rounding (Repeating Fractions): Just as $1/3$ produces an infinite repeating decimal in base 10 ($0.333\dots$), common decimal fractions like $0.1$ and $0.2$ produce repeating infinite sequences in base 2 ($0.0001100110011\dots_2$). This explains why 64-bit IEEE 754 floating-point operations in JavaScript and Python exhibit minor rounding imprecisions (e.g.,
0.1 + 0.2 = 0.30000000000000004). - Bit-Width Truncation & Overflow: Exceeding an integer register width causes overflow. For instance, in an 8-bit unsigned integer, adding 1 to 255 (
11111111) wraps around to 0 (00000000) due to carry-out bit truncation.
Quick Reference: 4-Bit Nibbles & Powers of 2
| Exponent | Power of 2 Value | 4-Bit Binary | Decimal Value | Hexadecimal | Octal |
|---|---|---|---|---|---|
| 20 | 1 | 0000 | 0 | 0x0 | 0o0 |
| 21 | 2 | 0001 | 1 | 0x1 | 0o1 |
| 22 | 4 | 0010 | 2 | 0x2 | 0o2 |
| 23 | 8 | 0011 | 3 | 0x3 | 0o3 |
| 24 | 16 | 0100 | 4 | 0x4 | 0o4 |
| 25 | 32 | 0101 | 5 | 0x5 | 0o5 |
| 26 | 64 | 0110 | 6 | 0x6 | 0o6 |
| 27 | 128 | 0111 | 7 | 0x7 | 0o7 |
| 28 | 256 | 1000 | 8 | 0x8 | 0o10 |
| 210 (1 KiB) | 1,024 | 1010 | 10 | 0xA | 0o12 |
| 212 | 4,096 | 1100 | 12 | 0xC | 0o14 |
| 216 (64 KiB) | 65,536 | 1111 | 15 | 0xF | 0o17 |
Clean Formula & Variable Key
Decimal = ∑i=0n−1 (bi × 2i)Fractional Binary Expansion Formula:
Decimal = ∑i=0n−1 (bi × 2i) + ∑j=1m (b−j × 2−j)Signed Two's Complement Formula (n-bit width):
Decimal = (−bn−1 × 2n−1) + ∑i=0n−2 (bi × 2i)
bi= Binary bit at integer positioni(0 or 1)2i= Positional weight corresponding to bit indexin= Total number of integer bits in the sequenceb−j= Fractional binary bit at positionjto the right of the radix point2−j= Fractional weight (0.5, 0.25, 0.125, etc.)bn−1= Most Significant Bit (MSB), which acts as the negative sign weight in two's complement
Working Example: Converting 11010110 to Decimal
Convert the 8-bit binary number 110101102 to base-10 decimal:
- Step 1: Write Each Digit with its Index:
Position 7:1| Position 6:1| Position 5:0| Position 4:1| Position 3:0| Position 2:1| Position 1:1| Position 0:0. - Step 2: Calculate Each Non-Zero Positional Weight:
1 × 27 = 128
1 × 26 = 64
1 × 24 = 16
1 × 22 = 4
1 × 21 = 2 - Step 3: Sum the Products:
128 + 64 + 16 + 4 + 2 = 214. - Step 4: Check Two's Complement Interpretation:
If treated as a signed 8-bit signed integer: −128 + 64 + 16 + 4 + 2 = −42.
Important Technical Terms
- Bit: The basic binary unit of digital information, representing either 0 or 1 (voltage off or on).
- Byte: A contiguous grouping of 8 bits, capable of representing 256 distinct unsigned values (0 to 255).
- Nibble: A 4-bit aggregation, precisely equal to one single hexadecimal digit (0x0 through 0xF).
- Most Significant Bit (MSB): The leftmost bit carrying the highest power-of-two magnitude, or the sign bit in signed notation.
- Least Significant Bit (LSB): The rightmost bit carrying the lowest power ($2^0 = 1$), which determines whether an integer is even or odd.
- Radix (Base): The number of unique digits used in a numeral system (Radix 2 for binary, 8 for octal, 10 for decimal, 16 for hexadecimal).
- Two's Complement: The standard digital logic system for expressing signed integers, where taking the bitwise NOT and adding 1 negates any number.
Frequently Asked Questions
Methodology, Sources & Limitations
Conversion algorithms follow ANSI/IEEE 754-2019 binary floating-point specifications and ISO/IEC 10646 standard character encoding rules. Positional radix transformations utilize standard discrete mathematics and computer engineering principles.
Assumptions & Limitations: Integer operations utilize arbitrary-precision BigInt for exact calculation up to practical browser memory constraints. Fractional binary conversions use standard IEEE 754 double precision up to 53 bits of fractional mantissa. Character previews assume UTF-8/ASCII mapping for codes between 32 and 255.