300 in binary is 100101100, a 9-bit sequence that represents the decimal value three hundred in base-2 mathematics. While converting numbers on paper is a basic computer science exercise, understanding the physical footprint of "300" is critical in embedded electronics and digital logic design. People commonly confuse the three decimal digits of "300" with binary bits, mistakenly assuming the value fits inside a standard 8-bit microcontroller register. In a real circuit or embedded system, attempting to store this 9-bit value in an 8-bit variable (like a byte or uint8_t) causes a silent integer overflow, wrapping the value to 44 and fundamentally breaking your control logic, PWM output, or sensor thresholds.
The Math: Converting Decimal 300 to Binary
To understand why 300 breaks standard 8-bit boundaries, we need to look at the powers of 2. In digital electronics, each bit represents a doubling of the previous value. An 8-bit system maxes out at $2^8 - 1$, which is 255. Because 300 is greater than 255, we must step up to the 9th bit ($2^8 = 256$).
Here is the exact subtraction method used to derive the binary sequence:
| Bit Position | Power of 2 | Value | Subtraction Step | Bit State |
|---|---|---|---|---|
| Bit 8 | $2^8$ | 256 | 300 - 256 = 44 | 1 |
| Bit 7 | $2^7$ | 128 | 44 < 128 (Skip) | 0 |
| Bit 6 | $2^6$ | 64 | 44 < 64 (Skip) | 0 |
| Bit 5 | $2^5$ | 32 | 44 - 32 = 12 | 1 |
| Bit 4 | $2^4$ | 16 | 12 < 16 (Skip) | 0 |
| Bit 3 | $2^3$ | 8 | 12 - 8 = 4 | 1 |
| Bit 2 | $2^2$ | 4 | 4 - 4 = 0 | 1 |
| Bit 1 | $2^1$ | 2 | 0 < 2 (Skip) | 0 |
| Bit 0 | $2^0$ | 1 | 0 < 1 (Skip) | 0 |
Reading the bit states from Bit 8 down to Bit 0, we get 100101100. For readability in code, we typically group this into nibbles or standard byte alignments, padding the left side if necessary: 0000 0001 0010 1100 (when stored in a 16-bit integer).
Where You Meet 300 in Practice
You will rarely type "300" as a raw binary literal in a schematic, but you will constantly encounter values around 300 when reading sensors or configuring timers. Here is where this specific numeric range intersects with physical hardware:
- 10-Bit Analog-to-Digital Converters (ADC): The classic ATmega328P microcontroller (used on the Arduino Uno) features a 10-bit ADC. This means
analogRead()returns values from 0 to 1023. A return value of 300 is a very common mid-range reading, representing approximately 1.46V on a 5V reference system. - PWM Timer Limits: If you are using an 8-bit hardware timer to generate a PWM signal, the maximum duty cycle register value is 255. If your control algorithm calculates a required duty cycle of 300 based on a PID loop, sending that directly to an 8-bit compare register will cause hardware-level wrap-around, resulting in a drastically lower duty cycle than intended.
- 9-Bit Sensor Payloads: Certain digital temperature sensors (like the TMP102 in extended mode) or specialized I2C light sensors output 9-bit or 12-bit data payloads. If a sensor returns a raw 9-bit integer of 300, your I2C read function must be configured to read two bytes and bit-shift the result, rather than reading a single 8-bit byte.
The 8-Bit Overflow Trap (Worked Numeric Example)
To understand what happens when you force a 9-bit value into an 8-bit space, think of an 8-bit register like a physical bucket that holds exactly 255 liters of water. If you try to pour 300 liters into it, the bucket overflows, and exactly 44 liters spill over the edge into a secondary drain. The microcontroller only "sees" the 44 liters that spilled, completely losing the original 300-liter volume.
Mathematically, this is a modulo operation: $300 \pmod{256} = 44$.
Here is a worked example showing the failure mode and the correct implementation using a 16-bit unsigned integer (uint16_t), which can safely hold up to 65,535.
// THE BUG: Using an 8-bit variable
uint8_t sensor_reading = 300; // Compiler warning: overflow
// sensor_reading actually stores 44!
if (sensor_reading > 250) {
// This logic block WILL NOT execute, because 44 is not > 250
trigger_alarm();
}
// THE FIX: Using a 16-bit variable
uint16_t safe_sensor_reading = 300;
// safe_sensor_reading correctly stores 300 (Binary: 00000001 00101100)
if (safe_sensor_reading > 250) {
// This logic block EXECUTES correctly
trigger_alarm();
}
When working with shift registers like the 74HC595, the shiftOut() function only accepts a byte (8 bits). If you pass 300 into shiftOut(), it will only clock out the lowest 8 bits (00101100), leaving the 9th bit behind. To shift out a 9-bit or 16-bit value, you must call shiftOut() twice, manually handling the most significant byte (MSB) and least significant byte (LSB).
FAQ: Common Questions About 300 in Binary
How do I write binary 300 in an Arduino sketch?
In C++, you can write binary literals directly using the 0b prefix. However, because 300 requires 9 bits, you must assign it to a 16-bit variable.
uint16_t myVal = 0b100101100;
If you try to assign 0b100101100 to a standard byte or uint8_t, the compiler will truncate the leading '1' and store only 00101100 (decimal 44).
Why does my 74HC595 shift register output the wrong pins when I send 300?
The 74HC595 is an 8-bit serial-in, parallel-out shift register. It physically only has 8 output pins (Q0 to Q7). It is impossible to send a 9-bit value like 300 to a single 8-bit shift register. The Arduino shiftOut() function will silently drop the 9th bit (the 256 value) and only shift the remaining 8 bits (00101100). If you need to control 9 or more pins, you must daisy-chain two 74HC595 chips together and write a custom function to shift out 16 bits sequentially.
What exact voltage does an ADC reading of 300 represent on a 5V system?
On a standard 5V microcontroller with a 10-bit ADC (like the Arduino Uno or Nano), the resolution is $5.0V / 1023 = 0.00488V$ per step. To find the voltage for a raw reading of 300, multiply: $300 \times 0.00488V = \mathbf{1.464V}$. If you are using an ESP32 with a 12-bit ADC (0-4095) and a 3.3V reference, a reading of 300 would represent $300 \times (3.3V / 4095) = \mathbf{0.241V}$.






