Converting a decimal with fraction to binary means translating a base-10 number containing a fractional part into a base-2 format by splitting it into integer and fractional components. In physical circuits, this math directly dictates the exact digital code word a Digital-to-Analog Converter (DAC) requires to output a precise analog voltage, or how an Analog-to-Digital Converter (ADC) quantizes a sensor reading into discrete steps. Most beginners confuse this raw fractional binary conversion with IEEE 754 floating-point encoding, which is an entirely different standard that uses sign, exponent, and mantissa bits to store decimals in microcontrollers.
The Core Method: Splitting Integer and Fractional Parts
You cannot convert a mixed decimal number in a single pass. The standard algorithm requires you to split the number at the radix point (the decimal dot), convert the integer half using repeated division, and convert the fractional half using repeated multiplication.
For the integer side, you divide by 2 and record the remainder (reading bottom-up). For the fractional side, you multiply by 2 and record the whole number carry (reading top-down). Think of the fractional multiplication like pouring water from a 1-liter pitcher into 0.5-liter cups; every time you fill a cup (reach 1.0 or more), you mark a '1' and keep pouring the remainder into the next cup.
Worked Numeric Example: Converting 13.6875
Let's break down 13.6875 into its binary equivalent.
Step 1: The Integer Part (13)
| Division | Quotient | Remainder |
|---|---|---|
| 13 / 2 | 6 | 1 (LSB) |
| 6 / 2 | 3 | 0 |
| 3 / 2 | 1 | 1 |
| 1 / 2 | 0 | 1 (MSB) |
Reading the remainders from bottom to top, the integer 13 is 1101.
Step 2: The Fractional Part (0.6875)
| Multiplication | Result | Carry Bit |
|---|---|---|
| 0.6875 * 2 | 1.375 | 1 (MSB) |
| 0.375 * 2 | 0.75 | 0 |
| 0.75 * 2 | 1.5 | 1 |
| 0.5 * 2 | 1.0 | 1 (LSB) |
Reading the carry bits from top to bottom, the fraction 0.6875 is .1011. Because the result hit exactly 1.0, the conversion terminates cleanly.
Where You Meet This in Practice (Circuits & Embedded)
You rarely write raw fractional binary strings in high-level firmware, but the underlying hardware relies on this exact math to bridge the digital and analog domains. According to the Texas Instruments Data Converters documentation, mapping digital registers to analog voltages requires understanding the binary weight of fractional bits.
DAC Voltage Scaling
Suppose you are using an MCP4725, a common 12-bit I2C DAC, with a 3.3V reference. The DAC accepts a 12-bit integer (0 to 4095). If your circuit requires an exact analog bias voltage of 2.0625V, you must calculate the required register value:
- Target ratio: 2.0625V / 3.3V = 0.625
- Register value: 0.625 * 4095 = 2559.375 (rounds to 2559)
- Binary register: 100111111111
If you were designing a custom fixed-point FPGA logic block instead of using an off-the-shelf DAC, you would use the fractional binary method to define the bit-width. A 4-bit fractional resolution gives you steps of 0.0625 (1/16th), while an 8-bit fractional resolution gives you steps of 0.00390625 (1/256th).
PWM Duty Cycle Calculations
When configuring hardware PWM timers on an ESP32 or STM32, duty cycles are often expressed as fractions. A 75.5% duty cycle is 0.755 in decimal. If your timer has an 8-bit resolution (255 steps), 0.755 * 255 = 192.5. You must decide whether to truncate to 192 (11000000) or round to 193 (11000001). Understanding how the fractional binary expansion behaves helps you predict the analog ripple this rounding error will introduce on your output filter.
Common Confusions: Fixed-Point vs. Floating-Point (IEEE 754)
The most frequent mistake hobbyists make is assuming that the binary string 1101.1011 is how an Arduino or ESP32 stores the number 13.6875 in memory. It is not.
Raw fractional binary is a fixed-point representation. The radix point is implied by the hardware designer at a specific bit boundary. This is heavily used in DSP (Digital Signal Processing) chips and FPGAs where execution speed is critical and memory is tight.
Microcontrollers, however, use the IEEE 754 standard for float variables. If you declare float val = 13.6875; in C++, the 32-bit memory register does not hold 1101.1011. Instead, it stores:
- Sign bit (1 bit): 0 (positive)
- Exponent (8 bits): 10000010 (biased representation of 3)
- Mantissa (23 bits): 10110110000000000000000 (the normalized significant digits)
float variable is experiencing precision loss in memory.
For a deeper dive into how digital logic handles these conversions at the gate level, the All About Circuits Digital Textbook provides excellent schematics on the shift registers used to perform these multiplications in silicon.
Frequently Asked Questions
How do you convert a repeating decimal with fraction to binary?
You use the exact same repeated multiplication method, but you stop when you hit your hardware's bit-width limit. For example, converting 0.1 (decimal) to binary results in an infinitely repeating sequence (0.0001100110011...). In a 8-bit fractional register, you simply truncate or round the sequence to the 8th bit, accepting the quantization error inherent in the hardware.
Why does my decimal with fraction to binary conversion never end?
A fractional decimal will only terminate cleanly in binary if the denominator of its reduced fraction form is a power of 2 (e.g., 2, 4, 8, 16). Because 0.6875 is exactly 11/16, it terminates. Because 0.1 is 1/10, and 10 is not a power of 2, it repeats infinitely in base-2, just like 1/3 repeats infinitely in base-10 (0.333...).
What is the fastest way to check a decimal with fraction to binary math?
Use the negative powers of 2 as a verification checksum. For the fractional part .1011, calculate: (1 * 2^-1) + (0 * 2^-2) + (1 * 2^-3) + (1 * 2^-4). This equals 0.5 + 0 + 0.125 + 0.0625, which sums exactly to 0.6875. If your sum matches your original decimal fraction, your conversion is correct.






