The binary table for numbers is the definitive lookup for translating base-2 logic states (HIGH/LOW, 1/0) into human-readable decimal and hexadecimal values. If you are configuring an ESP32 GPIO register, setting an I2C address, or debugging a bitwise operation, the direct answer is that an 8-bit binary sequence like 10100101 equals 165 in decimal and 0xA5 in hex. Mastering this table eliminates the guesswork when writing firmware for microcontrollers or tracing digital logic on an oscilloscope.
The Master Binary Table for Numbers (Base Nibble & Byte Boundaries)
Before reading the table, understand its structure. The foundation of all binary math relies on the 4-bit "nibble" (0-15). Any 8-bit, 16-bit, or 32-bit number is simply a concatenation of these base patterns. The values below conform to the positional notation defined in ISO/IEC 80000-13 (Information science and technology) and the C99 stdint.h standard used by Arduino and ESP-IDF compilers.
| Decimal | Hexadecimal | Binary (Raw) | 8-Bit Padded (uint8_t) | Common Electronics Use Case |
|---|---|---|---|---|
| 0 | 0x0 | 0000 | 00000000 | Logic LOW / GND reference |
| 1 | 0x1 | 0001 | 00000001 | Bit 0 mask (Pin 0) |
| 2 | 0x2 | 0010 | 00000010 | Bit 1 mask (Pin 1) |
| 3 | 0x3 | 0011 | 00000011 | I2C address suffix / 2-pin combo |
| 4 | 0x4 | 0100 | 00000100 | Bit 2 mask (Pin 2) |
| 5 | 0x5 | 0101 | 00000101 | Alternating bit pattern test |
| 6 | 0x6 | 0110 | 00000110 | RS-232 / UART framing bits |
| 7 | 0x7 | 0111 | 00000111 | 3-bit DAC max value |
| 8 | 0x8 | 1000 | 00001000 | Bit 3 mask (Pin 3 / MSB of nibble) |
| 9 | 0x9 | 1001 | 00001001 | BCD (Binary Coded Decimal) 9 |
| 10 | 0xA | 1010 | 00001010 | SPI clock polarity/phase (CPOL/CPHA) |
| 11 | 0xB | 1011 | 00001011 | Hex B (often used in MAC addresses) |
| 12 | 0xC | 1100 | 00001100 | I2C start/stop condition masks |
| 13 | 0xD | 1101 | 00001101 | UART baud rate divisor fragments |
| 14 | 0xE | 1110 | 00001110 | Hex E (EEPROM page boundaries) |
| 15 | 0xF | 1111 | 00001111 | Lower nibble mask (0x0F) |
Bookmark-Friendly Quick-Jump: Byte & Register Boundaries
When working beyond 4 bits, you rarely need the full 0-255 sequence. You need the boundary values that dictate when a variable overflows or when a specific hardware register maxes out. Reference these rows directly when sizing variables in C/C++.
| Data Type | Bits | Max Unsigned (Decimal) | Max Unsigned (Hex) | Binary Representation |
|---|---|---|---|---|
uint8_t / byte | 8 | 255 | 0xFF | 11111111 |
uint16_t / unsigned int | 16 | 65,535 | 0xFFFF | 11111111 11111111 |
uint32_t | 32 | 4,294,967,295 | 0xFFFFFFFF | 11111111... (32 ones) |
int8_t (Signed) | 8 | 127 | 0x7F | 01111111 |
Which Column Applies to Your Installation?
Choosing the right column depends entirely on the hardware layer you are interacting with. Using decimal for hardware registers leads to unreadable code and bitwise errors.
- Use the Binary Column (Padded) when: You are manipulating individual GPIO pins on a port register. For example, setting pins 2 and 3 HIGH on an AVR ATmega328P requires writing
0b00001100to the PORTD register. Binary makes the physical pin mapping visually explicit. - Use the Hexadecimal Column when: You are configuring I2C addresses, SPI control registers, or memory pointers. An SSD1306 OLED display initializes at
0x3C. Reading0x3Cinstantly tells an engineer that the lower nibble is1100and the upper is0011. Decimal60hides this hardware reality. - Use the Decimal Column when: You are performing human-scale math, such as calculating PWM duty cycles (e.g.,
analogWrite(pin, 128)for 50% duty cycle on an 8-bit timer) or converting ADC sensor readings to real-world voltage.
How Signed Formats and Bit-Shifting Modify Base Values
In wire sizing, temperature derating modifies the base ampacity. In binary logic, Two's Complement and Bit-Shifting modify the base decimal value. If you assume a binary table is strictly positive, your microcontroller will silently invert your logic when handling negative sensor data or reverse motor directions.
int8_t), the microcontroller flips all bits of the positive binary value and adds 1. Therefore, decimal -1 is not 10000001 (which is -127 in signed magnitude); it is 11111111 (0xFF). If you pass 0xFF to an unsigned variable, it reads as 255. This mismatch is the #1 cause of "ghost" bugs in embedded C.Bit-Shifting Modifiers: Shifting a binary number left by one position (<< 1) multiplies the base value by 2. Shifting right (>> 1) divides by 2. This is how hardware registers scale values without using CPU-heavy multiplication instructions.
- Base Value:
00000011(Decimal 3) - Shift Left 2 (
<< 2):00001100(Decimal 12) - Shift Right 1 (
>> 1):00000001(Decimal 1, note the lost fractional bit)
Decision Path: Selecting Your Data Type and Bitmask
Use this decision tree to terminate your debugging process and select the exact C/C++ data type and bitmask required for your firmware. Default to unsigned integers unless your sensor explicitly outputs negative values.
| Condition / Task | Required Action | Concrete Pick (Code / Value) |
|---|---|---|
| Reading a single GPIO pin state from a 32-bit register (ESP32) | Isolate the target bit using bitwise AND and a shifted mask | if (REG_READ(GPIO_IN_REG) & (1 << PIN_NUM)) |
| Configuring an I2C peripheral address | Use 7-bit Hexadecimal (ignore the R/W LSB for standard Arduino Wire library) | 0x3C (OLED) or 0x68 (MPU6050) |
| Storing an ADC reading (0-4095 on ESP32 12-bit ADC) | Use a 16-bit unsigned integer to prevent 8-bit overflow | uint16_t adc_val = analogRead(34); |
| Clearing a specific bit in a control register without affecting others | Use bitwise AND with the inverted mask (NOT operator) | REG &= ~(1 << BIT_POS); |
| Handling temperature data that drops below 0°C | Use a signed 16-bit integer to preserve the Two's Complement sign bit | int16_t temp_raw = read_sensor(); |
What the Binary Table Cannot Tell You (Hardware Limits)
While the binary table for numbers provides the mathematical truth, it lacks the physical context of your specific silicon. Keep these three hardware limitations in mind when translating table values to physical wiring:
- Endianness (Byte Order): The table assumes you are reading a single byte. When you move to 16-bit or 32-bit numbers, the ESP32 (Xtensa architecture) and Arduino Uno (AVR) are Little-Endian. This means the least significant byte is stored at the lowest memory address. If you read a 16-bit hex value
0x1234directly from memory byte-by-byte, you will read0x34first, then0x12. Network protocols (like MQTT or TCP/IP) require Big-Endian, forcing you to use byte-swap functions before transmission. - I2C 7-Bit vs. 8-Bit Addressing: The standard I2C specification uses a 7-bit address, but the physical bus transmits 8 bits (the 8th bit is the Read/Write flag). If a datasheet lists an I2C address as
0xD0, it is likely showing the 8-bit shifted value. You must shift it right by one (0xD0 >> 1) to get the0x68value required by the ArduinoWire.hlibrary. - Logic Level Voltages: A binary
1does not universally mean 5 Volts. On an Arduino Uno (ATmega328P), a1is 5V. On an ESP32-WROOM-32, a1is 3.3V. Feeding a 5V binary HIGH into a 3.3V ESP32 GPIO pin without a logic level converter or voltage divider will destroy the silicon, regardless of what the binary table says.
For authoritative details on microcontroller data types, refer to the Arduino Language Reference for byte/uint8_t. For deeper hardware register manipulation on 32-bit systems, consult the Espressif ESP32 GPIO API Reference. Standardized binary prefix definitions (like Kibi vs. Kilo) are maintained by NIST Binary Prefixes guidelines.






