To convert the fractional decimal 0.6875 to binary, the exact answer is 0.1011. When programming microcontrollers like the ESP32 or AVR-based Arduino, you rarely pass raw decimals to low-level DAC or PWM registers; you need the exact binary fraction representation. This guide provides the immediate conversion math, reference tables, and the architectural decision framework to map these fractions to 8-bit, 16-bit, or 32-bit hardware registers without losing precision.

The Multiplication Method: Formula and Step-by-Step

The standard algorithm to convert a fractional decimal to binary is repeated multiplication by 2. You multiply the fractional part by 2, record the integer part (which will always be 0 or 1), and repeat the process with the new fractional remainder until the remainder reaches zero or you hit your target bit-width.

Formula Substitution for 0.6875:
1. 0.6875 × 2 = 1.375 → Integer is 1, remainder is 0.375
2. 0.375 × 2 = 0.75 → Integer is 0, remainder is 0.75
3. 0.75 × 2 = 1.5 → Integer is 1, remainder is 0.5
4. 0.5 × 2 = 1.0 → Integer is 1, remainder is 0.0 (Stop)

Reading the integers from top to bottom yields the binary fraction 0.1011. Because the remainder reached exactly 0.0, this is a terminating binary fraction, meaning it can be represented perfectly in digital logic without rounding errors.

Neighboring Values Reference Table (±20% Range)

When tuning analog outputs or calibrating sensor thresholds, you rarely need just one value. Below is a spec-sheet-style reference table for decimal fractions within a ±20% range of our target (0.5500 to 0.8250), mapped to their 8-bit binary equivalents. Note that values with an ellipsis (...) indicate infinite repeating binary fractions that require truncation.

Decimal FractionBinary Fraction (Raw)8-Bit Register Value (Hex)Terminating?
0.55000.10001100...0x8CNo
0.62500.10100xA0Yes
0.68750.10110xB0Yes
0.75000.110xC0Yes
0.81250.11010xD0Yes
0.82500.11010011...0xD3No

What Assumption Fixes the Answer? Bit-Width and Number Formats

In AC power theory, assumptions like voltage, power factor, and phase angle fix your calculations. In digital logic, the assumption that fixes a fractional binary answer is the bit-width and the number format (Fixed-Point Q-format vs. IEEE 754 Floating-Point). A raw binary fraction like 0.1011 is mathematically pure, but meaningless to a compiler until you assign it a container.

How the Answer Shifts Across Architectures

  • 8-Bit Fixed-Point (e.g., AVR DAC/PWM): The fraction is scaled by $2^8$ (256). For 0.6875, the calculation is $0.6875 \times 255 = 175.125$. You truncate or round to 175 (0xAF). The resolution is limited to steps of ~0.0039.
  • 16-Bit Fixed-Point (e.g., Q15 Format on DSPs): The fraction is scaled by $2^{15}$ (32768). For 0.6875, the value is exactly 22528 (0x5800). This is heavily used in audio processing on chips like the Teensy 4.1.
  • 32-Bit Floating-Point (e.g., ESP32, STM32): The hardware uses the IEEE 754 standard. The decimal 0.6875 is encoded in memory as the 32-bit hex value 0x3F300000.

When the Conversion is Meaningless

Attempting to convert an infinite repeating binary fraction—like the decimal 0.1—is mathematically meaningless unless you define a truncation boundary and a rounding mode. Decimal 0.1 in binary is 0.0001100110011... repeating infinitely. If you ask 'what is 0.1 in binary?' without specifying an 8-bit, 16-bit, or 32-bit container, the question cannot be answered for hardware implementation. In 32-bit IEEE 754 float, 0.1 is actually stored as 0x3DCCCCCD, which evaluates back to 0.10000000149011612.

Decision Tree: Fixed-Point vs. Floating-Point Implementation

Use this decision path to determine how to handle your converted binary fractions in your embedded C/C++ firmware.

Condition / Hardware ConstraintAction & FormatConcrete Pick
MCU lacks hardware FPU (e.g., ATmega328P, Arduino Uno)Use 16-bit Fixed-Point (Q8 or Q15) to avoid massive software float overhead.Use int16_t Q8 math
MCU has hardware FPU (e.g., ESP32, STM32F4)Use native 32-bit floats for readability; the compiler handles IEEE 754 mapping.Use float (32-bit)
Writing directly to an 8-bit DAC registerMultiply decimal by 255, cast to uint8_t. Do not use raw binary fractions.Use uint8_t scaled math
High-speed motor control loop (FOC) requiring <1μs executionUse 32-bit Fixed-Point (Q16 or Q24) to utilize single-cycle MAC (Multiply-Accumulate) instructions.Use int32_t Q16 math

Real-World Hardware Mapping: ESP32 DAC and PWM Registers

Let's apply the converted fraction 0.6875 to a real-world scenario. Suppose you are driving the ESP32's 8-bit DAC on GPIO 25 to output a specific reference voltage. The ESP32 DAC accepts values from 0 to 255, mapping to roughly 0V to 3.3V.

Callout Tip: Never write binary fractions directly to DAC APIs.
While the binary fraction is 0.1011, the ESP-IDF dac_output_voltage() function expects an integer. You must scale the fraction to the hardware's bit-depth: 0.6875 * 255 = 175.125. Cast this to uint8_t to get 175. Writing 175 to the DAC yields an output of approximately 2.26V.

If you are instead using the ESP32's LEDC peripheral for PWM duty cycle control with a 10-bit resolution (0-1023), your scaling shifts: $0.6875 \times 1023 = 703.3125$. You would write 703 to the duty cycle register. The underlying binary fraction remains the same, but the hardware register scaling dictates the final integer you pass to the API.

FAQ: Common Fractional Binary Conversion Errors

Why does my 0.1 decimal fraction cause jitter in my PID control loop?
Because 0.1 is an infinite repeating binary fraction (0.000110011...). If you are using 8-bit or 16-bit fixed-point math, the truncation error compounds on every loop iteration. Switch to 32-bit floating-point (float) on an ESP32, or use a terminating fraction like 0.125 (0.001) for your tuning constants to eliminate accumulation jitter.

How do I convert a mixed number like 5.6875 to binary?
Split it into integer and fractional parts. Convert the integer 5 to binary normally (101). Convert the fractional 0.6875 using the multiplication method above (0.1011). Combine them with a binary point: 101.1011.

Is there a difference between signed and unsigned fractional binary?
Yes. The conversions above assume unsigned fractions (values between 0.0 and 0.999). If you need negative fractions (e.g., -0.6875 for AC waveform generation), you must use Two's Complement representation. In an 8-bit signed system (Q7 format), -0.6875 is represented as 1.0101000 in binary, or 0xA8 in hex.