To answer how to convert a binary number into decimal directly: the 8-bit binary sequence 11010110 converts to 214 in standard unsigned decimal, but -42 if interpreted as a signed two's complement integer. The foundational formula is D = Σ(bi × 2i). Substituting our values for 11010110 (reading right-to-left from bit 0): (0×1) + (1×2) + (1×4) + (0×8) + (1×16) + (0×32) + (1×64) + (1×128) = 214. Whether you are parsing a raw I2C register dump from an ESP32-S3 or debugging a microcontroller fault code, knowing the exact decimal equivalent—and the data type assumptions behind it—is the critical first step.

Step-by-Step Substitution and Neighboring Values

The base-2 positional system assigns a weight to each bit based on its index, starting at 0 on the far right. When you map a binary string to a base-10 integer, you are simply summing the weights of the '1' bits. For our target value 11010110, the active bits are at positions 1, 2, 4, 6, and 7. Summing those powers of two (2 + 4 + 16 + 64 + 128) yields 214.

When debugging digital logic or reviewing hex dumps, it helps to see the surrounding neighborhood. Below is a reference table covering a ±20% range around our target decimal value (172 to 250), showing how the binary shifts and how the signed two's complement interpretation behaves concurrently.

Binary (8-bit)Unsigned DecimalSigned Decimal (Two's Complement)Hex Equivalent
10101100172-840xAC
10111000184-720xB8
11000100196-600xC4
11010000208-480xD0
11010110214-420xD6
11100010226-300xE2
11101110238-180xEE
11111010250-60xFA

Reference Table: Powers of Two (Bit 0 to Bit 15)

Memorizing every power of two is unnecessary, but having a quick-reference spec sheet on your bench saves time when you are manually masking bits or calculating ADC resolution limits. The table below covers the first 16 bits, which encompasses the standard 8-bit and 16-bit registers found on most AVR, PIC, and ARM Cortex-M microcontrollers.

Bit Position (i)Power of 2 (2i)Decimal WeightHex Mask
02010x0001
12120x0002
22240x0004
32380x0008
424160x0010
525320x0020
626640x0040
7271280x0080
8282560x0100
9295120x0200
102101,0240x0400
112112,0480x0800
122124,0960x1000
132138,1920x2000
1421416,3840x4000
1521532,7680x8000

For deeper digital logic fundamentals, refer to resources like the Khan Academy Binary Numbers module.

Assumptions That Fix Your Answer (Signed vs. Unsigned & Bit-Width)

In AC power calculations, your answer shifts depending on whether you assume 120V single-phase or 208V three-phase. In binary conversion, the equivalent assumption that fixes your answer is the data type definition (unsigned vs. signed) and the bit-width (8-bit vs. 16-bit vs. 32-bit). A raw string of 1s and 0s has no inherent numerical meaning until the system's architecture defines how to read it.

How the Answer Shifts Across Representations

If you pull the byte 11010110 from a sensor register, the decimal output shifts drastically based on how your C/C++ code casts the variable:

RepresentationBinary InputDecimal OutputCore Assumption
8-bit Unsigned (uint8_t)11010110214All bits are positive weights. Range: 0 to 255.
8-bit Signed (int8_t)11010110-42MSB (Bit 7) is the sign bit. Uses Two's Complement. Range: -128 to 127.
16-bit Unsigned (uint16_t)00000000 11010110214Padded to 16 bits. The value remains positive and identical.
16-bit Signed (int16_t)00000000 11010110214MSB (Bit 15) is 0, so it is read as a positive integer.

When the Conversion is Meaningless

Blindly applying the base-2 integer formula yields garbage data if the binary string represents encoded formats rather than raw integers. The conversion is mathematically valid but practically meaningless in these scenarios:

  • IEEE 754 Floating-Point: If your 32-bit binary sequence represents a float (as defined by the IEEE 754 Standard), the bits are split into a sign bit, an 8-bit exponent, and a 23-bit mantissa. Summing them as positional powers of two will give you a massive, incorrect integer instead of the actual decimal fraction (e.g., 01000000100100100000000000000000 is 4.5625 in float, not 1,083,244,544).
  • Binary-Coded Decimal (BCD): In BCD, each 4-bit nibble represents a single decimal digit (0-9). The binary 1001 0110 in BCD means '96', but standard base-2 conversion yields 150.
  • ASCII / UTF-8 Text: The byte 01000001 converts to 65 in decimal, but in a serial terminal, it represents the uppercase character 'A'.

FAQ: Binary to Decimal Edge Cases

Can I convert fractional binary numbers into decimal?
Yes. The formula extends to the right of the binary point using negative powers of two. For example, 101.11 converts to (1×4) + (0×2) + (1×1) + (1×0.5) + (1×0.25) = 5.75 in decimal.

Does endianness change the decimal conversion?
Endianness (Big-Endian vs. Little-Endian) only matters when you are combining multiple bytes into a larger integer (like combining two 8-bit registers into a 16-bit value). For a single, isolated binary string, endianness does not apply; you always read the least significant bit (LSB) on the far right.

Why does my microcontroller print a negative number for a large sensor reading?
You are likely experiencing an overflow or a signed-casting error. If a sensor outputs an unsigned 8-bit value of 214 (11010110), but your code stores it in a signed 8-bit integer (int8_t), the compiler reads the leading '1' as a negative sign bit, instantly converting your 214 into -42. Always match your variable types to the sensor's datasheet specifications.