The 8-bit binary sequence 11010110 converts exactly to the decimal integer 214. This direct answer assumes you are reading an unsigned, big-endian (MSB-first) byte, which is the standard mathematical default. The foundational positional formula used to get here is D = Σ(bi × 2i). Substituting our specific bit values from right (index 0) to left (index 7):
(1 × 27) + (1 × 26) + (0 × 25) + (1 × 24) + (0 × 23) + (1 × 22) + (1 × 21) + (0 × 20)
= 128 + 64 + 0 + 16 + 0 + 4 + 2 + 0 = 214
When you are pulling raw bytes off an I2C or SPI bus, however, treating every binary string as a simple unsigned integer is a fast track to misinterpreting sensor data. Below is the bench-tested framework for converting binary registers to usable decimal values in microcontroller environments.
The Core Formula and the ±20% Neighborhood
Memorizing the powers of two (1, 2, 4, 8, 16, 32, 64, 128) lets you do this math in your head while debugging with a logic analyzer. To give you a frame of reference for signal drift or ADC stepping, here is a reference table covering the ±20% range around our target value of 214 (spanning roughly 171 to 256).
| Decimal | 8-Bit Binary | Hex Equivalent | Common Embedded Context |
|---|---|---|---|
| 171 | 10101011 |
0xAB |
Lower bound of ±20% window |
| 192 | 11000000 |
0xC0 |
Mid-range threshold (often a 75% duty cycle in 8-bit PWM) |
| 214 | 11010110 |
0xD6 |
Target Query Value |
| 235 | 11101011 |
0xEB |
Upper-mid range (high PWM duty cycle) |
| 255 | 11111111 |
0xFF |
Maximum 8-bit unsigned bound (100% duty / 3.3V logic HIGH) |
What Assumptions Fix the Answer (And How Context Shifts It)
The decimal answer 214 is only correct if three assumptions hold true: the data is 8 bits wide, it is unsigned, and it is read big-endian (Most Significant Bit first). In embedded systems, just like assuming a wall outlet is 120V when you're actually standing in Europe, ignoring the data format will fry your logic.
11010110 from an LM75 temperature sensor's 8-bit signed register, the leading 1 flags it as a negative number in Two's Complement format. The decimal answer violently shifts from 214 to -42.
Here is how the decimal answer shifts based on the architectural context of the register you are reading:
- 8-Bit Unsigned (Default): The answer is 214. Used for raw GPIO port states, 8-bit PWM duty cycles, and device ID registers.
- 8-Bit Signed (Two's Complement): The answer is -42. Used for temperature offsets, accelerometer delta axes, and error codes.
- 16-Bit Little-Endian (Lower Byte): If this byte is the LSB of a 16-bit register (like an ESP32 12-bit ADC result padded to 16 bits), its positional weight remains 214, but the upper byte will add multiples of 256.
- 16-Bit Big-Endian (Upper Byte): If this byte is the MSB, its decimal contribution shifts by a factor of 28. The decimal value of just this byte's contribution becomes 54,784 (214 × 256).
Decision Tree: Interpreting Microcontroller Register Data
When you dump a raw binary byte from a logic analyzer or serial monitor, use this decision path to terminate on the exact C/C++ data type and decimal interpretation you need.
| IF your data source is... | AND the datasheet specifies... | THEN cast to this C/C++ type | Final Decimal Pick |
|---|---|---|---|
| GPIO Input Register (e.g., PORTB) | Raw pin states (0-255) | uint8_t |
214 |
| Temperature / Sensor Offset | Two's Complement (Signed) | int8_t |
-42 |
| 16-bit ADC / Timer Capture | Little-Endian (LSB first) | uint16_t (combine with next byte) |
214 + (NextByte × 256) |
| 32-bit Float Sensor (e.g., BMP280) | IEEE 754 Memory Dump | float (via memcpy or union) |
See Section Below |
Default Recommendation: If you are reverse-engineering an unknown 8-bit I2C register and the datasheet is missing, default to uint8_t (Unsigned 214) for configuration/ID registers, but immediately test int8_t (Signed -42) if the values represent physical measurements that can cross zero.
When Binary-to-Decimal Conversion is Meaningless
There is a specific scenario where applying the standard polynomial formula to a binary string yields a mathematically correct but practically useless number: IEEE 754 floating-point memory dumps.
Suppose you are reading a 32-bit register from a high-precision power monitor over SPI, and the first byte you clock in is 01000000. If you blindly apply the binary-to-decimal formula, you get 64. But if that sensor is outputting a 32-bit float representing a voltage reading of 3.14V, the entire 32-bit binary sequence is 01000000010010001111010111000011.
If you run the standard integer conversion on that full 32-bit string, your calculator will output 1,078,523,331. This decimal number is completely meaningless on the bench. Floating-point numbers divide their bits into sign, exponent, and mantissa fields, not standard positional weights. To convert this, you must bypass integer math entirely and map the raw bytes directly into a floating-point variable in memory using a pointer cast or a memcpy function in your Arduino/ESP32 sketch.
FAQ: Quick Conversion Edge Cases
What if the binary string has fewer than 8 bits, like 10110?
Pad it with leading zeros to match your register width. 10110 becomes 00010110. The decimal conversion remains exactly the same: 16 + 4 + 2 = 22. Leading zeros carry no positional weight.
How do I handle 12-bit ADC values that arrive in two 8-bit I2C bytes?
Microcontrollers like the ESP32 often right-align 12-bit ADC results (0-4095) into 16-bit registers. You will receive a High Byte and a Low Byte. Convert both to decimal, multiply the High Byte's decimal value by 256, and add the Low Byte's decimal value. Do not attempt to convert the raw 16-bit binary string directly if the upper 4 bits are just padding.
Where can I verify standard register formats for my specific MCU?
Always check the manufacturer's technical reference manual. For Espressif chips, the ESP32 Technical Reference Manual explicitly defines whether peripheral registers are read-only, write-only, or Two's Complement. For foundational digital logic and binary arithmetic rules, the All About Circuits Digital Textbook remains the industry-standard open reference.






