A binary number chart maps base-2 bits to decimal, hexadecimal, and hardware logic states. For embedded systems and digital logic, the most critical values are powers of two (used for single-bit manipulation), nibble masks (0x0F, 0xF0), and alternating bit patterns (0x55, 0xAA) used for bus testing. While standard base-2 arithmetic is universal, translating those 1s and 0s into physical voltages on a breadboard requires understanding logic family thresholds.
This reference provides the exact mathematical conversions you need for register manipulation, followed by the hardware voltage mappings required to ensure your microcontroller actually reads those bits correctly.
The Core Binary Number Chart (Decimal, Hex, and Signed)
How to read this table: This chart covers the most queried 8-bit and 4-bit values in embedded programming. The Binary column shows the raw bits (MSB to LSB). The Hex column is what you will type into your C/C++ code (e.g., 0x80). The Unsigned column is the standard positive integer value. The Signed (Two's Complement) column applies when the MSB (bit 7) acts as a sign indicator—critical when reading differential channels on a 12-bit ADC or handling negative sensor offsets. Standard base-2 conversions follow ISO/IEC 80000-13 arithmetic conventions.
| Binary (8-Bit) | Hex | Decimal (Unsigned) | Decimal (Signed) | Common Application / Mask Name |
|---|---|---|---|---|
| 0000 0001 | 0x01 | 1 | 1 | Bit 0 set (LSB) |
| 0000 1111 | 0x0F | 15 | 15 | Lower Nibble Mask |
| 0001 0000 | 0x10 | 16 | 16 | Bit 4 set |
| 0011 1111 | 0x3F | 63 | 63 | 6-bit I2C Address Mask |
| 0101 0101 | 0x55 | 85 | 85 | Alternating 0/1 (Bus Test Low) |
| 0111 1111 | 0x7F | 127 | 127 | Max Positive 8-bit Signed |
| 1000 0000 | 0x80 | 128 | -128 | Bit 7 set (MSB) / Min Signed |
| 1010 1010 | 0xAA | 170 | -86 | Alternating 1/0 (Bus Test High) |
| 1111 0000 | 0xF0 | 240 | -16 | Upper Nibble Mask |
| 1111 1111 | 0xFF | 255 | -1 | All bits set / Max Unsigned |
~0x08 or 0xF7).
Hardware Logic Levels: Translating Binary to Voltage
A '1' or '0' in your code must be represented by physical voltage on a wire. According to Texas Instruments' Logic Family Guide (SDYA010) and JEDEC JESD8 standards, the exact voltage required to register a binary HIGH ($V_{IH}$) or LOW ($V_{IL}$) depends entirely on your logic family and supply voltage ($V_{CC}$).
| Logic Family | Typical VCC | $V_{IL}$ (Max LOW) | $V_{IH}$ (Min HIGH) | Best Used With |
|---|---|---|---|---|
| 74LS (TTL) | 5.0V | 0.8V | 2.0V | Legacy 5V Arduino (Uno/Mega) |
| 74HC (CMOS) | 5.0V | 1.5V (0.3×VCC) | 3.5V (0.7×VCC) | 5V Shift Registers (SN74HC595) |
| LVCMOS (3.3V) | 3.3V | 0.8V | 2.0V | ESP32, STM32, Raspberry Pi Pico |
| LVCMOS (1.8V) | 1.8V | 0.45V | 1.26V | Low-power wearables, BMS ICs |
Which Column Applies to Your Installation?
Look at your microcontroller's operating voltage. If you are using an ESP32-WROOM-32 or a Raspberry Pi Pico, your GPIO pins operate at 3.3V. You must use the LVCMOS (3.3V) column. If you connect a 5V 74HC logic chip directly to an ESP32 without a level shifter, the ESP32's 3.3V HIGH output will fall short of the 74HC's 3.5V $V_{IH}$ requirement, resulting in intermittent or completely missed binary reads.
How Derating Modifies the Base Thresholds
Logic thresholds are not static; they derate based on temperature and supply sag. For CMOS families (like 74HC), $V_{IH}$ is defined as $0.7 imes V_{CC}$. If your 5V USB supply sags to 4.5V under a heavy motor load, your new $V_{IH}$ threshold drops to 3.15V. While this makes it 'easier' to read a HIGH, the $V_{IL}$ threshold also drops to 1.35V, shrinking your noise margin. In extreme temperature environments (e.g., an automotive engine bay hitting 85°C), silicon leakage increases, further degrading the noise margin and potentially causing a binary '0' to float up into the undefined region between $V_{IL}$ and $V_{IH}$.
What the Table Cannot Tell You
Voltage threshold charts omit three critical hardware realities:
- Propagation Delay ($t_{pd}$): The time it takes for a physical gate to switch states after the input crosses the threshold (typically 5ns to 20ns for modern CMOS).
- Current Drive Limits: An ESP32 pin might output a valid 3.3V binary HIGH, but it can only source roughly 40mA total across all GPIO pins. Exceeding this causes internal trace damage.
- Setup and Hold Times: When clocking data into a shift register, the binary data must be stable for a specific number of nanoseconds before and after the clock edge.
Applying the Chart: Bitmasking in Embedded C++
Knowing the hex and binary values is only half the battle; you must apply them to hardware registers without disturbing adjacent bits. This is done using bitwise operators. Below is the standard framework for manipulating an 8-bit hardware register (like a port direction register or an I2C configuration byte) on an Arduino or ESP32.
1. Setting a Bit (Forcing a 1):
Use the bitwise OR (|) operator with a power of two from the chart.
REG |= 0x08; // Sets Bit 3 (0000 1000), leaves others unchanged
2. Clearing a Bit (Forcing a 0):
Use the bitwise AND (&) operator with the bitwise NOT (~) of the target mask.
REG &= ~0x04; // Clears Bit 2 (1111 1011), leaves others unchanged
3. Toggling a Bit (Flipping State):
Use the bitwise XOR (^) operator.
REG ^= 0x80; // Flips Bit 7 (MSB)
4. Extracting a Nibble:
Use the bitwise AND with a nibble mask to isolate specific bits, such as reading the lower 4 bits of an ADC result.
uint8_t lower_half = ADC_RESULT & 0x0F; // Masks out upper 4 bits
0x55 (01010101) followed by 0xAA (10101010) to a dummy register or toggle a GPIO pin with these patterns. The alternating bits force maximum edge transitions, allowing you to measure the exact rise and fall times on an oscilloscope to check for excessive parasitic capacitance on the SDA/SCL lines.






