Binary for 3 is the base-2 numerical representation of the decimal value three, written as 11 (or 0011 in a standard 4-bit nibble), where each digit represents a successive power of two. In digital electronics and embedded systems, this isn't just abstract math; it is a physical state of voltage levels on a bus, a hardware register, or a set of GPIO pins. When you configure a microcontroller, set hardware jumpers, or write firmware, understanding exactly how the value 3 translates to physical logic highs and lows prevents addressing collisions, misconfigured ICs, and silent firmware bugs.

The Core Translation: Decimal 3 to Binary 11

To use binary for 3 in a real circuit, you must understand how it scales across different bit-widths and encoding schemes. A microcontroller doesn't just see '3'; it sees a specific pattern of bits padded to the width of its data bus (usually 8, 16, or 32 bits). Below is the exact translation of decimal 3 across the digital encoding formats you will encounter in datasheets and logic analyzer software.

Encoding Scheme Notation Bit Pattern (8-bit) Physical 3.3V Logic States (Bits 7 to 0) Common Use Case
Standard Binary 0b00000011 00000011 L-L-L-L-L-L-H-H GPIO pin states, shift registers
Hexadecimal 0x03 00000011 L-L-L-L-L-L-H-H I2C addresses, memory mapping
BCD (8421) 0x03 00000011 L-L-L-L-L-L-H-H 7-segment displays, RTC chips
Gray Code 0b00000010 00000010 L-L-L-L-L-L-H-L Rotary encoders, position sensors
Excess-3 0b00000110 00000110 L-L-L-L-L-H-H-L Legacy arithmetic logic units
Bench Note: Notice that in Gray Code, decimal 3 is 0010, not 0011. If you are reading a rotary encoder and assume standard binary, your position tracking will jump erratically between states. Always check the datasheet's encoding table.

Worked Numeric Example: 74HC595 Shift Register at 3.3V

Let’s look at what binary for 3 actually looks like on an oscilloscope when driving a standard 74HC595 shift register powered by a 3.3V VCC. To output a decimal 3, the microcontroller shifts in 00000011.

  • Bit 0 (LSB): Logic HIGH. Measured voltage: 3.28V. (Exceeds the 74HC family $V_{IH}$ minimum threshold of $0.7 imes V_{CC}$, or 2.31V).
  • Bit 1: Logic HIGH. Measured voltage: 3.28V.
  • Bits 2 through 7: Logic LOW. Measured voltage: 0.04V. (Well below the $V_{IL}$ maximum threshold of $0.3 imes V_{CC}$, or 0.99V).

The math holds up on the bench: $(1 imes 2^0) + (1 imes 2^1) + (0 imes 2^2) ... = 1 + 2 = 3$. The physical reality is two pins sourcing current at ~3.3V, while the other six sink to ground.

Where You Meet Binary for 3 in Practice

Understanding this bit pattern changes how you physically wire and configure real circuits. You will most frequently encounter binary for 3 when setting hardware addresses or configuring hardware-level modes via DIP switches and jumper pins.

1. Setting I2C Bus Addresses (PCF8574 I/O Expander)

The NXP PCF8574 I/O expander uses three address pins (A0, A1, A2) to allow up to eight chips on the same I2C bus. The base address for the standard PCF8574 is 0x20 (binary 0100000). The state of the A-pins is appended to the least significant bits.

If you wire A0 to HIGH (3.3V), A1 to HIGH (3.3V), and A2 to LOW (GND), you are feeding the chip the binary value 011 (decimal 3). The chip's internal logic shifts this into the address register, resulting in a final 7-bit I2C address of 0100011 (Hex 0x23). If you mistakenly wire A2 HIGH as well, you send binary 111 (decimal 7), shifting the address to 0x27 and causing your microcontroller to fail to acknowledge the device.

2. Stepper Driver Microstepping (Allegro A4988)

On the ubiquitous Allegro A4988 stepper driver, three pins (MS1, MS2, MS3) dictate the microstepping resolution. If you treat MS1 as the LSB and MS3 as the MSB, setting MS1=HIGH, MS2=HIGH, and MS3=LOW inputs the binary value 011 (decimal 3) into the driver's logic gate matrix. According to the A4988 truth table, this specific binary for 3 configuration commands the driver to operate in 1/8 microstep mode. This physically changes the current decay stepping in the H-bridge, resulting in significantly smoother motor rotation and less acoustic resonance compared to full-step mode.

Common Confusions: Binary 11 vs. Decimal 11 vs. Hex 3

The most frequent point of failure for hobbyists and junior engineers is misinterpreting the visual representation of the number 3 in code and schematics. Here is what people commonly confuse it with:

The Golden Rule of Digital Notation: 11 in binary is 3 in decimal. 11 in decimal is 1011 in binary. Never assume the base without a prefix.
  • The Unprefixed '11' Trap: In C, C++, and Arduino IDE, writing int mode = 11; assigns the decimal value eleven (binary 1011). If you intended to set a 2-bit register to maximum (binary 11), your code will overflow the register or write to unintended higher bits. You must explicitly use the binary prefix: int mode = 0b11; or the legacy Arduino macro B00000011.
  • Hexadecimal Overlap: Hexadecimal 0x3 is exactly the same value as binary 0b11. However, beginners often confuse 0x11 with binary 11. Hex 0x11 is actually decimal 17 (binary 00010001). When reading I2C scanner outputs, an address of 0x11 is not 'binary 11'—it is a completely different device on the bus.
  • BCD Misinterpretation: In Binary Coded Decimal, each nibble (4 bits) represents a single decimal digit from 0-9. While decimal 3 is 0011 in BCD, decimal 11 in BCD is 0001 0001. If you pass standard binary 0b1011 (decimal 11) to a BCD-to-7-segment decoder like the CD4511, the chip will blank the display because 1011 is an invalid BCD state (greater than 9).

Practical Bitwise Operations Using 0b11

When writing firmware for an ESP32 or Arduino, you rarely assign a whole byte just to set two pins. You use bitwise math to manipulate binary for 3 (0b11) as a mask. This allows you to change specific bits in a hardware register without disturbing the rest of the system.

Extracting the Lower Two Bits (Masking)

If you read an 8-bit status register from a sensor and only care about the error codes stored in the lowest two bits, you use the bitwise AND operator (&) with 0b11.

uint8_t status = readSensorRegister(); // e.g., returns 0b10110111
uint8_t errorCode = status & 0b11;     // Results in 0b11 (Decimal 3)

The 0b11 mask acts as a filter. The upper six bits are ANDed with 0 (forcing them to 0), while the lower two bits retain their original state.

Clearing Specific Bits

To force the lowest two bits of a configuration register to LOW (0) while leaving the rest untouched, you combine the bitwise AND with the bitwise NOT (~) operator:

REG &= ~0b11; // Inverts 0b11 to 0b11111100, clearing bits 0 and 1

Setting Specific Bits

To force the lowest two bits HIGH (to set a value of 3) without altering the upper bits, use the bitwise OR (|) operator:

REG |= 0b11; // Forces bits 0 and 1 HIGH, leaving bits 2-7 unchanged

Frequently Asked Questions

Q: Can I just use decimal 3 instead of 0b11 in my Arduino code?
A: Yes, the compiler treats REG |= 3; and REG |= 0b11; identically. However, using 0b11 is a best practice for hardware registers because it visually maps to the physical pins and datasheets, reducing cognitive load when debugging.

Q: Why does my I2C scanner show address 0x23 when I set my DIP switches to 3?
A: The DIP switches are providing the binary offset (decimal 3, or 011). The I2C chip adds this offset to its hardcoded base address (e.g., 0x20). 0x20 + 0x03 = 0x23.

Q: Is binary 11 the same as a 2-bit integer?
A: A 2-bit unsigned integer has a maximum value of 3 (binary 11). If you attempt to store decimal 4 in a strictly 2-bit variable, it will overflow and wrap around to 0.