When converting binary numbers to decimal, the direct answer depends entirely on the specific bit string you are evaluating. For the standard 8-bit unsigned binary sequence 10110101, the exact decimal conversion is 181. The universal formula used is D = Σ(b_i × 2^i), where b is the bit value (0 or 1) and i is the position index starting from 0 at the Least Significant Bit (LSB). Substituting our values: (1×2^7) + (0×2^6) + (1×2^5) + (1×2^4) + (0×2^3) + (1×2^2) + (0×2^1) + (1×2^0) = 128 + 0 + 32 + 16 + 0 + 4 + 0 + 1 = 181.

Just as AC power calculations require you to lock in assumptions like voltage, power factor, and phase, a raw binary-to-decimal conversion is only mathematically valid once you fix your word length, signedness, and data format. Below is the foundational reference data you need on the bench before we explore how those assumptions shift the final number.

Table 1: 8-Bit Positional Weight Reference (Spec Sheet)

Bit Position (i) 7 (MSB) 6 5 4 3 2 1 0 (LSB)
Weight (2^i) 128 64 32 16 8 4 2 1
Target Bit (10110101) 1 0 1 1 0 1 0 1
Calculated Value 128 0 32 16 0 4 0 1

Table 2: Neighboring Decimal Values (±20% Range of 181)

When debugging sensor thresholds or PWM registers, you rarely look at a single number in isolation. Here is how the binary shifts across a ±20% window (145 to 217) around our target value of 181.

Decimal 8-Bit Binary Hexadecimal Deviation from 181
145100100010x91-20.0% (Lower Bound)
160101000000xA0-11.6%
175101011110xAF-3.3%
181101101010xB50.0% (Target)
195110000110xC3+7.7%
210110100100xD2+16.0%
217110110010xD9+19.9% (Upper Bound)

The Assumptions That Fix Your Decimal Answer

If you feed 10110101 into a basic calculator, you get 181. But if you are reading this byte directly from an ESP32 memory register or an Arduino Uno (ATmega328P) serial buffer, 181 might be completely wrong. The final decimal output shifts dramatically based on three hardware-level assumptions:

1. Word Length (8-bit vs. 16-bit vs. 32-bit)
An 8-bit microcontroller like the ATmega328P natively caps unsigned integers at 255. If your binary string is actually part of a 16-bit register (e.g., reading a 12-bit ADC value over I2C), the surrounding byte dictates the true value. If 10110101 is the lower byte and the upper byte is 00000011, the 16-bit binary is 0000001110110101, shifting the decimal answer from 181 to 949.

2. Signed vs. Unsigned (Two's Complement)
In embedded C/C++, an 8-bit uint8_t treats the Most Significant Bit (MSB) as a standard 128 weight, yielding 181. However, if the variable is declared as an int8_t (signed), the MSB acts as a negative sign indicator using Two's Complement arithmetic. The formula shifts to: -128 + (0×64) + 32 + 16 + 0 + 4 + 0 + 1. The exact same binary string 10110101 suddenly evaluates to -75.

3. Endianness (Byte Ordering)
When converting multi-byte binary streams from sensors (like the BME280 over SPI), you must know if the hardware transmits Little-Endian (LSB first, common in ARM/ESP32) or Big-Endian (MSB first, common in network protocols). Swapping the byte order of a 16-bit value will entirely invert your decimal result.

When Raw Binary-to-Decimal Conversion is Meaningless

Applying the standard positional weight formula assumes the binary string represents a raw, base-2 integer. In modern electronics, you will frequently encounter binary data where standard conversion yields mathematical garbage. The conversion becomes meaningless in the following scenarios:

⚠️ Warning: IEEE 754 Floating-Point Data
If you are reading a 32-bit temperature or GPS coordinate from a sensor, the data is likely encoded in the IEEE 754 single-precision standard. For example, the binary 01000000010010010000111111011011 does not equal 1,078,525,915. It is structured as 1 sign bit, 8 exponent bits, and 23 mantissa bits. Interpreted correctly via IEEE 754, that exact binary string represents the decimal floating-point value 3.1415927 (Pi). Applying standard integer conversion here will completely break your firmware logic.

Binary-Coded Decimal (BCD)
Real-Time Clock (RTC) modules like the DS3231 often store time in BCD to simplify 7-segment display driving. In BCD, each 4-bit nibble represents a single decimal digit (0-9). The binary 0010 0101 in standard math is 37. But in BCD, the upper nibble is 2 and the lower is 5, meaning the decimal value is 25 (e.g., 25 minutes past the hour). Standard conversion will yield the wrong time.

ASCII / UTF-8 Text Encoding
If you are parsing a serial stream from a GPS module or a 3D printer mainboard, the binary represents character codes. The 8-bit binary 01000001 mathematically converts to 65. But in the context of a serial buffer, it is the ASCII character 'A'. Treating text payloads as raw integers is a primary cause of parsing errors in Arduino Serial.read() routines.

Embedded Systems FAQ: Debugging Binary on the Bench

Q: Why does my ESP32 print negative numbers when my sensor outputs high binary values?
A: You are likely storing an 8-bit sensor reading in a signed int or int8_t variable instead of an unsigned uint8_t. Any binary string where the MSB is 1 (decimal values 128 through 255) will trigger the Two's Complement sign bit, wrapping the decimal output into the negative range (-128 to -1). Change your variable declaration to uint8_t or byte.

Q: How do I quickly verify a 16-bit binary string without doing the math manually?
A: Group the binary into 4-bit nibbles and convert to Hexadecimal first. It is much faster for the human brain to map 1011 0101 to 0xB5 and then use a standard hex-to-decimal mental shortcut (or calculator) than to sum eight individual powers of two. In C/C++, you can force the compiler to do it by assigning int val = 0b10110101; and printing it via Serial.println(val, DEC);.

Q: My logic analyzer shows a 12-bit binary string, but my microcontroller reads it wrong. Why?
A: 12-bit ADCs (like the ADS1015) often left-align or right-align their data within a 16-bit I2C register. If the data is left-aligned, the 12 bits are shifted 4 positions to the left, padding the LSBs with zeros. You must bit-shift the raw decimal result right by 4 (raw >> 4) to get the true decimal representation of the analog voltage.