The core binary to decimal chart translates base-2 bit weights into base-10 integers. For standard 8-bit microcontroller ports and DIP switches, the maximum decimal value is 255. When you flip switch 1 and switch 3 on an 8-channel DIP block, you are setting binary 00000101, which translates directly to a decimal 5. Below is the complete reference data, engineered for embedded systems builders, Arduino hobbyists, and ESP32 developers who need to map physical hardware states to software registers.
The Master Binary to Decimal Chart
How to read this table: This chart is based on the fundamental base-2 positional numeral system as defined in ISO/IEC 80000-2 standard digital logic conventions. The Bit Weight column represents the multiplier ($2^n$). To find the decimal value of any binary string, simply sum the Bit Weights for every position where the binary digit is '1'. The Hexadecimal column is included because most C/C++ compilers and datasheets require hex prefixes (e.g., 0xFF) for bitmask operations.
| Bit Position ($n$) | Bit Weight ($2^n$) | Binary (8-Bit) | Unsigned Decimal | Hexadecimal |
|---|---|---|---|---|
| 0 | 1 | 00000001 | 1 | 0x01 |
| 1 | 2 | 00000010 | 2 | 0x02 |
| 2 | 4 | 00000100 | 4 | 0x04 |
| 3 | 8 | 00001000 | 8 | 0x08 |
| 4 | 16 | 00010000 | 16 | 0x10 |
| 5 | 32 | 00100000 | 32 | 0x20 |
| 6 | 64 | 01000000 | 64 | 0x40 |
| 7 | 128 | 10000000 | 128 | 0x80 |
| All High | Sum(0-7) | 11111111 | 255 | 0xFF |
| 16-Bit & 32-Bit Milestones | ||||
| 8 | 256 | 00000001 00000000 | 256 | 0x100 |
| 10 | 1024 | 00000100 00000000 | 1024 | 0x400 |
| 15 | 32768 | 10000000 00000000 | 32768 | 0x8000 |
| 16 (Max) | 65535 | 11111111 11111111 | 65535 | 0xFFFF |
| 25 | 33,554,432 | (32-bit register) | 33554432 | 0x2000000 |
| 32 (Max) | 4,294,967,295 | (32-bit register) | 4294967295 | 0xFFFFFFFF |
Architecture Mapping: Which Column Applies to Your Board?
Knowing the math is only half the battle; you must know which column applies to your specific microcontroller architecture. Applying an 8-bit decimal value to a 32-bit register won't break anything, but attempting to write a 16-bit value to an 8-bit hardware port will cause a bitwise overflow, truncating your data and causing erratic hardware behavior.
- 8-Bit Architectures (Arduino Uno / ATmega328P): Direct port manipulation registers like
PORTBandPORTDare strictly 8-bit. Your maximum decimal ceiling is 255. If you are reading an 8-channel DIP switch wired to PORTD, a reading of binary10100000translates to decimal 160. - 16-Bit Architectures (Timers and ADCs): Hardware timers (like Timer1 on the ATmega328P) and high-resolution Analog-to-Digital Converters operate on 16-bit registers. Your ceiling is 65,535. A 10-bit ADC reading (max 1023) fits comfortably inside this 16-bit column.
- 32-Bit Architectures (ESP32 / STM32): Modern SoCs use 32-bit wide GPIO registers. According to the Espressif ESP32 Technical Reference Manual, writing directly to the
GPIO_OUT_W1TS_REG(Write 1 to Set) requires 32-bit decimal values. To set GPIO 25 high via direct register manipulation, you don't write '25'; you write $2^{25}$, which is decimal33554432(or1UL << 25in C++).
Signed Integers: How Two's Complement Modifies Base Values
In electrical wire sizing, NEC temperature derating rows modify the base ampacity of a conductor based on ambient heat. In binary conversion, signed integer formats (Two's Complement) act as the 'derating row' that modifies the base unsigned decimal value of a binary string.
If your microcontroller variable is declared as an unsigned int, binary 10000000 equals decimal 128. However, if you declare that same variable as a standard signed int8_t, the most significant bit (MSB) becomes a sign indicator rather than a positive weight. The binary string 10000000 is suddenly 'derated' to decimal -128.
Binary to Decimal Chart FAQ
How do I convert a 10-bit binary ADC reading to a decimal voltage?
A standard 10-bit ADC (like the one on the Arduino Uno) outputs a decimal range from 0 to 1023. To convert this binary/decimal reading into a real-world voltage, use the formula: Voltage = (Decimal_Reading / 1023.0) * Vref. If your reference voltage (Vref) is 5.0V and your serial monitor outputs a decimal 512, the math is (512 / 1023.0) * 5.0 = 2.50V. Always use 1023.0 (floating point) in your code to prevent integer division truncation.
Why does my I2C address chart show 0x3C in hex but 60 in decimal?
I2C addresses are fundamentally 7-bit binary numbers, but they are almost universally documented in hexadecimal. 0x3C in hex translates to binary 0111100, which is decimal 60. However, be careful with microcontroller libraries. Some I2C libraries (like older Arduino Wire implementations) require the 8-bit shifted address. They take the 7-bit address (0x3C), shift it left by one bit to make room for the Read/Write flag, resulting in 0x78 (decimal 120). Always check your specific library's documentation to see if it expects the 7-bit or 8-bit shifted decimal value.
How do I calculate the decimal value of a 32-bit ESP32 GPIO bitmask?
When configuring multiple pins simultaneously on a 32-bit board like the ESP32, you use bitmasks. If you need to set GPIO 2, GPIO 4, and GPIO 5 high, you look up their bit weights in the chart: 4 ($2^2$), 16 ($2^4$), and 32 ($2^5$). Sum those decimal values: 4 + 16 + 32 = 52. In your C++ code, rather than hardcoding the decimal 52, it is vastly more readable and less error-prone to use bitwise shift operators: (1UL << 2) | (1UL << 4) | (1UL << 5). The compiler resolves this to the exact same binary sequence at build time.






