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)HexDecimal (Unsigned)Decimal (Signed)Common Application / Mask Name
0000 00010x0111Bit 0 set (LSB)
0000 11110x0F1515Lower Nibble Mask
0001 00000x101616Bit 4 set
0011 11110x3F63636-bit I2C Address Mask
0101 01010x558585Alternating 0/1 (Bus Test Low)
0111 11110x7F127127Max Positive 8-bit Signed
1000 00000x80128-128Bit 7 set (MSB) / Min Signed
1010 10100xAA170-86Alternating 1/0 (Bus Test High)
1111 00000xF0240-16Upper Nibble Mask
1111 11110xFF255-1All bits set / Max Unsigned
Bookmark Quick-Jump: If you are configuring an I2C device, the 7-bit address is always shifted left by one (e.g., address 0x3F becomes 0x7E on the wire). If you are clearing a register, use the bitwise NOT of the target bit (e.g., to clear bit 3, AND the register with ~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 FamilyTypical VCC$V_{IL}$ (Max LOW)$V_{IH}$ (Min HIGH)Best Used With
74LS (TTL)5.0V0.8V2.0VLegacy 5V Arduino (Uno/Mega)
74HC (CMOS)5.0V1.5V (0.3×VCC)3.5V (0.7×VCC)5V Shift Registers (SN74HC595)
LVCMOS (3.3V)3.3V0.8V2.0VESP32, STM32, Raspberry Pi Pico
LVCMOS (1.8V)1.8V0.45V1.26VLow-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

Pro-Tip for I2C Debugging: If your I2C bus is locking up, write 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.