Binary Fraction Converter
Convert decimal fractions to binary and binary fractions to decimal with step-by-step workings, repeating pattern detection, and precision control.
About
Converting fractional numbers between decimal (base-10) and binary (base-2) is a non-trivial operation that underpins floating-point representation in every modern processor. A seemingly simple decimal value like 0.1 produces an infinitely repeating binary fraction 0.0001100110011…, which is why floating-point arithmetic accumulates rounding errors. Misunderstanding this mechanism leads to real bugs: financial calculations drift, physics simulations diverge, and comparison operators return unexpected results. This tool performs exact positional arithmetic - not floating-point approximation - and exposes every multiplication step so you can verify the conversion by hand.
The fractional conversion algorithm multiplies the fractional part by 2 repeatedly, extracting the integer bit at each iteration. The tool tracks previously seen remainders to detect repeating cycles and marks them with vinculum notation. Integer parts use standard repeated division. Precision is capped at 64 binary digits to match double-precision significance. Note: this tool assumes unsigned magnitudes. For negative values, apply two's complement or sign-magnitude encoding separately after conversion.
Formulas
Decimal-to-binary fractional conversion uses repeated multiplication. Given a decimal fraction f where 0 ≤ f < 1:
where bi ∈ {0, 1} is the extracted binary digit and ri is the remaining fractional part. Repeat with f ← ri until r = 0 or maximum precision is reached. The binary fraction is 0.b1b2b3…
For the integer part, repeated division is used:
Binary-to-decimal reversal applies positional weighting:
where bi is the i-th bit after the binary point, and D is the resulting decimal value. Repeating patterns occur when a remainder rj equals a previously seen remainder rk where k < j. The cycle length is j − k.
Reference Data
| Decimal Fraction | Binary Fraction | Repeating? | Period Length | Exact in IEEE 754 float32? |
|---|---|---|---|---|
| 0.5 | 0.1 | No | 0 | Yes |
| 0.25 | 0.01 | No | 0 | Yes |
| 0.125 | 0.001 | No | 0 | Yes |
| 0.0625 | 0.0001 | No | 0 | Yes |
| 0.75 | 0.11 | No | 0 | Yes |
| 0.1 | 0.00011 | Yes | 4 | No |
| 0.2 | 0.0011 | Yes | 4 | No |
| 0.3 | 0.01001 | Yes | 4 | No |
| 0.4 | 0.0110 | Yes | 4 | No |
| 0.6 | 0.1001 | Yes | 4 | No |
| 0.7 | 0.10110 | Yes | 4 | No |
| 0.8 | 0.1100 | Yes | 4 | No |
| 0.9 | 0.11100 | Yes | 4 | No |
| 0.375 | 0.011 | No | 0 | Yes |
| 0.6875 | 0.1011 | No | 0 | Yes |
| 0.1875 | 0.0011 | No | 0 | Yes |
| 1.0 | 1.0 | No | 0 | Yes |
| 3.14159 | 11.001001… | Yes (irrational) | ∞ | No |
| 10.625 | 1010.101 | No | 0 | Yes |
| 0.333… | 0.01 | Yes | 2 | No |