Converting the fractional decimal 0.625 to pure binary yields 0.101. When applied to a real-world microcontroller—such as reading a 0.625V analog signal on an ESP32’s 12-bit ADC with a 3.3V reference—this fraction maps to the decimal count 775, represented as the 12-bit binary word 0011 0000 0111. The governing formula is Count = (Vin / Vref) × 2n. Substituting our bench values: (0.625 / 3.3) × 4096 = 775.75, which the SAR (Successive Approximation Register) hardware truncates to 775. This guide bridges pure binary math with the hardware realities of analog-to-digital conversion.

The Core Assumptions: Bit-Depth and Reference Rails

In pure mathematics, converting a fraction like 0.1 (decimal) to binary results in an infinitely repeating sequence (0.000110011...). In electrical engineering, a fractional decimal to binary converter is physically bound by two assumptions that fix the answer:

  • Bit-Depth (n): The number of bits the ADC uses to slice the voltage range (e.g., 10-bit, 12-bit, 16-bit). This dictates your maximum denominator (2n).
  • Reference Voltage (Vref): The physical ceiling of the measurement. A 0.625V signal means something entirely different on a 1.2V rail versus a 5.0V rail.
Bench Tip: Never assume an ESP32's internal 12-bit ADC is perfectly linear. The actual usable range is often 0.1V to 3.1V due to internal transistor saturation. For precision fractional math below 0.1V, you must amplify the signal or use an external ADC.

Scaling the Fraction: 1.2V vs 3.3V vs 5.0V References

How does the binary output shift when you change the reference voltage? If we hold our input at exactly 0.625V and use a 12-bit resolution (4096 steps), the binary word changes drastically based on the system's logic level.

Reference Rail (Vref)Step Size (mV)Decimal Count12-Bit Binary Word
1.2V (Low-power IoT)0.293 mV21331000 0101 0101
3.3V (Standard ESP32/STM32)0.805 mV7750011 0000 0111
5.0V (Classic Arduino Uno)1.220 mV5120010 0000 0000

Notice that on a 5.0V reference, 0.625V yields exactly 512—a clean binary 0010 0000 0000. This is because 0.625V is exactly 1/8th of 5.0V, and 1/8th of 4096 is 512. Choosing a Vref that aligns with your expected fractional voltages can eliminate rounding errors in your firmware.

High-Voltage AC Adaptation: 120V, 230V, and 3-Phase

When measuring mains AC, you cannot feed 120V or 230V directly into a microcontroller. You must step it down to a fractional DC range using a voltage divider or a ZMPT101B voltage transformer. Here is how the conversion shifts across global mains standards:

  • 120V RMS (North America): The peak voltage is ~169V. A standard 100:1 divider scales this to a 1.69V peak AC signal. Biasing this to a 1.65V DC offset keeps the entire AC wave within a 0V–3.3V ADC window. The fractional binary conversion now represents an oscillating value centered around the 2048 count.
  • 230V RMS (EU/UK/AU): The peak voltage is ~325V. You must increase your divider ratio (e.g., 200:1) to scale the peak down to 1.625V. If you accidentally use the 120V divider ratio on a 230V grid, the signal will clip at the 3.3V rail, rendering the peak binary snapshots meaningless (hard-coded to 1111 1111 1111).
  • 3-Phase Systems: Measuring 3-phase requires three synchronized fractional conversions. Because the phases are 120° apart, taking sequential ADC readings introduces a time-skew error. You must use a simultaneous-sampling ADC (like the TI ADS8688) to capture all three binary fractions at the exact same microsecond, otherwise your calculated vector sum and power factor will be fundamentally flawed.

Neighboring Fractional Values (±20% Range)

When calibrating sensors, it helps to see how the binary word increments around your target value. Below is a reference chart for a 12-bit ADC on a 3.3V reference, spanning ±20% around our 0.625V benchmark.

Input Voltage (V)Decimal Count12-Bit Binary OutputHex Equivalent
0.50006200010 0110 11000x26C
0.56256980010 1011 10100x2BA
0.6250 (Target)7750011 0000 01110x307
0.68758530011 0101 01010x355
0.75009300011 1010 00100x3A2

When the Conversion is Meaningless

A fractional decimal to binary conversion yields useless data under three specific conditions:

  1. Violating the Nyquist Limit: If your analog signal frequency exceeds half your ADC sampling rate, aliasing occurs. The binary output will represent a completely different, lower-frequency phantom signal.
  2. Unknown or Drifting Vref: If your microcontroller is powered via a noisy USB line and you use VCC as your Vref, a 50mV drop in USB voltage alters the denominator in your formula. The binary count shifts even if the physical input voltage hasn't changed.
  3. IEEE 754 Floating-Point Limits: When passing these binary counts into 32-bit float variables in C/C++, remember that fractions like 0.1 cannot be represented perfectly in binary floating-point. For high-precision financial or scientific logging, transmit the raw integer binary counts over MQTT and let the server handle the decimal conversion using 64-bit doubles.

Decision Tree: Selecting Your Converter Hardware

Do not default to your microcontroller's internal ADC. Use this decision path to select the correct hardware for your fractional conversion needs.

Application RequirementConditionConcrete Hardware Pick
General hobby sensing (potentiometers, LDRs)If error tolerance > 5% and speed is lowInternal ESP32 12-bit SAR ADC
Precision DC voltage / Load cellsIf you need < 0.1% error and low noiseADS1115 (16-bit I2C Delta-Sigma)
High-speed AC waveform captureIf sampling > 100 kSPS for FFT analysisMCP3008 (10-bit SPI SAR, 200 kSPS)
3-Phase Mains Power MonitoringIf simultaneous sampling is mandatoryADE9000 (Dedicated Energy Metering IC)
Final Verdict: For 90% of precision DIY bench projects requiring accurate fractional decimal to binary conversion, bypass the internal MCU ADC and wire up an ADS1115. Its 16-bit resolution and internal precision reference eliminate the Vref drift that plagues USB-powered dev boards.

Frequently Asked Questions

Why does my 12-bit ADC never read exactly 4095?
By design, the maximum digital output of an N-bit ADC is 2N - 1. For a 12-bit converter, the ceiling is 4095 (1111 1111 1111). Furthermore, the transition to the maximum code typically occurs at Vref minus 1 LSB (Least Significant Bit), meaning you need an input slightly below Vref to hit the absolute maximum binary word.

Can I convert a negative fractional decimal to binary?
Standard unipolar ADCs cannot read negative voltages and will output 0000 0000 0000 (or potentially damage the silicon if below -0.3V). To convert negative fractions, you must use a bipolar ADC (like the ADS1115 in differential mode) or shift the signal into a positive range using an op-amp summing circuit before conversion.