Binary Fraction Converter
Enter a decimal number such as 0.625 or 13.5 and instantly get its binary fraction equivalent, complete with step-by-step working. Or enter a binary fraction like 1101.101 and convert it straight back to decimal. The tool shows how many bits the integer and fractional parts each need, detects repeating binary patterns (like the infinite 0.001100110011... that represents 0.2), and reports the rounding error introduced by truncating to your chosen precision.
What is a binary fraction?
A binary fraction is a number expressed in base 2 that includes digits to the right of the binary point, just as a decimal fraction has digits to the right of the decimal point. Each position to the right of the binary point represents a negative power of 2: the first position is 2^-1 = 0.5, the second is 2^-2 = 0.25, the third is 2^-3 = 0.125, and so on. So the binary fraction 0.101 equals 1 x 0.5 + 0 x 0.25 + 1 x 0.125 = 0.625 in decimal. Binary fractions are fundamental in computing because all floating-point numbers stored in hardware are simply binary fractions scaled by a power of 2 (the IEEE 754 standard).
How to convert decimal to binary fraction (repeated doubling)
Converting the integer part is straightforward: divide by 2 repeatedly and read the remainders upward. For the fractional part, use repeated doubling: multiply the fraction by 2, record the integer part (0 or 1) as the next binary digit, then repeat with just the fractional remainder. For example, to convert 0.625: 0.625 x 2 = 1.25 -> bit 1 is 1, remainder 0.25; 0.25 x 2 = 0.5 -> bit 2 is 0, remainder 0.5; 0.5 x 2 = 1.0 -> bit 3 is 1, remainder 0. The remainder is 0, so the process terminates exactly, giving 0.101 in binary. If the remainder never reaches 0, the binary fraction is infinite and repeating.
Why some fractions cannot be represented exactly in binary
A decimal fraction terminates in binary only when its denominator (in lowest terms) has no prime factors other than 2. So 1/2, 1/4, 3/8, and 5/16 are all exact in binary. But 1/10 (0.1) has a factor of 5 in the denominator, making it impossible to express as a finite binary fraction. Instead, 0.1 becomes the repeating binary 0.0001100110011..., which computers truncate to fit in a fixed number of bits. This is the root cause of the famous floating-point surprises in programming, such as 0.1 + 0.2 not equalling exactly 0.3.
IEEE 754 floating-point and binary fractions
Modern computers store most real numbers using the IEEE 754 standard, which encodes a number as a binary fraction (the significand) times a power of 2 (the exponent). A 32-bit single-precision float allocates 23 bits for the fractional part of the significand, giving about 7 significant decimal digits. A 64-bit double-precision float uses 52 bits, giving about 15-17 significant decimal digits. Choosing 24-bit or 52-bit precision in this calculator lets you see exactly how much rounding error a real CPU would introduce when storing your value.
Common decimal-to-binary fraction conversions
| Decimal | Fraction | Binary | Exact? |
|---|---|---|---|
| 0.5 | 1/2 | 0.1 | Yes |
| 0.25 | 1/4 | 0.01 | Yes |
| 0.75 | 3/4 | 0.11 | Yes |
| 0.125 | 1/8 | 0.001 | Yes |
| 0.625 | 5/8 | 0.101 | Yes |
| 0.1 | 1/10 | 0.0001100110011... (repeating) | No |
| 0.2 | 1/5 | 0.0011001100110011... (repeating) | No |
| 0.3 | 3/10 | 0.0100110011001100... (repeating) | No |
| 0.1 + 0.2 | - | 0.0100110011001101 (truncated) | No |
Fractions whose denominators are powers of 2 convert exactly. All others produce repeating binary fractions.
Frequently asked questions
How do I convert 0.1 to binary?
Multiply 0.1 by 2 repeatedly and collect the integer parts: 0.1 x 2 = 0.2 (bit: 0), 0.2 x 2 = 0.4 (bit: 0), 0.4 x 2 = 0.8 (bit: 0), 0.8 x 2 = 1.6 (bit: 1), 0.6 x 2 = 1.2 (bit: 1), and the pattern repeats every 4 bits. So 0.1 in binary is 0.0001100110011... (infinitely repeating). Computers truncate this, which is why 0.1 cannot be stored exactly in binary floating-point.
Which decimal fractions have exact binary representations?
Only fractions whose denominator (in lowest terms) is a power of 2 convert exactly: 1/2 = 0.5, 1/4 = 0.25, 3/4 = 0.75, 1/8 = 0.125, and so on. Any fraction whose denominator contains a prime factor other than 2 (such as 1/3, 1/5, 1/6, 1/10) will produce an infinite, repeating binary fraction.
Why does 0.1 + 0.2 not equal 0.3 in most programming languages?
Because 0.1, 0.2, and 0.3 all have infinite repeating binary representations, and the computer stores truncated approximations. When you add the truncated forms of 0.1 and 0.2 the rounding errors accumulate, giving a result that differs from the truncated form of 0.3 by about 5.55 x 10^-17. This is not a bug in the language but a consequence of binary floating-point arithmetic.
How do I convert a binary fraction back to decimal?
Sum the positional values of each 1 bit. Bits to the left of the binary point represent 2^0, 2^1, 2^2, and so on. Bits to the right represent 2^-1 = 0.5, 2^-2 = 0.25, 2^-3 = 0.125, and so on. For example, 1101.101 = 1x8 + 1x4 + 0x2 + 1x1 + 1x0.5 + 0x0.25 + 1x0.125 = 13.625.
What precision should I choose?
For general learning, 8 bits is a good starting point. If you want to match single-precision floating-point (what most GPUs and embedded systems use) choose 24 bits. For double-precision floating-point (the default in most desktop programming languages) choose 52 bits. More bits means a smaller rounding error but a longer binary string.
What is a repeating binary fraction?
Just as 1/3 = 0.33333... repeats in decimal, many fractions repeat in binary. For example, 1/5 = 0.001100110011... in binary, repeating the group 0011 forever. The calculator detects this automatically and tells you the period (length) of the repeating block.