Binary Fraction Converter
Converting integers to binary is easy; what about converting the decimal part? Learn how to do it with our binary fraction converter.
Get a better understanding of your computer with us. Here, we will teach you:
- What a binary fraction is.
- Where we use binary fractions.
- The limitations of a computer and the effect on rounding.
- How to convert from decimal fraction to binary fraction and vice-versa.
- How to use our binary fraction converter — it's simple, trust us!
Computers think in terms of ones and zeros — that's binary code, and it is everywhere. Peek behind this converter, and you'll see a lot of those numbers!
Converting integers numbers from base 10 (decimal) to base 2 (binary) is easy and doesn't introduce errors. The same holds when you consider a number written in positional notation (when you specify the position of a digit in a number). We can't say the same of decimal numbers as you would write them on a sheet of paper, like and .
What is a binary fraction?
Representing such values in base 2 brings us the binary fractions!
How to convert fractions to binary
Converting a decimal fraction to binary is not that hard. Take any decimal fraction: we chose . Make sure that the integer part is .
Now, multiply it by two, and see what happens.
The integer part remained : this is the first element of the binary fraction, . Repeat the step; we will see something different this time.
The integer part is now : the second element of our binary fraction will be : .
Remove the integer part (subtract ), and repeat the steps again and again; your binary fraction will grow!
It doesn't stop! Why is the binary fraction still growing? Let's take a look at the reason in the next section.
The conversion from binary fraction to decimal fraction
Now that you know how to convert from a decimal fraction to a binary let's learn the other way round. Take a binary fraction, any binary fraction! Did you think of ? Great — so did we. 😆
The rule behind this conversion is that every digit's position corresponds to a negative power of two.
🙋 We included the 0th power of two, which equals , only to give a better understanding of this positional conversion. Remember to limit your conversions to numbers smaller than !
Take your binary fraction and rewrite it, multiplying each digit by the respective power of 2. Then sum them together.
Convert the fractions to their decimal equivalents:
And that's it — we've converted a decimal fraction to a binary fraction!
The limitations of binary fractions
Binary fractions can't represent every decimal fraction perfectly. It's entirely possible for decimal fractions with a finite number of decimal digits (rational) to have an infinitely long binary representation. Such a conversion results in an error, with the magnitude of the error depending on the number of digits of the representation.
This is a geometric series that converges to . By removing elements ad hoc, you can obtain every number between and ; however, the real issue here is to decide which contributions we must erase.
Since computers have a limited amount of memory — they can compute only up to a certain number of digits — some contributions that allow for the exact representation of a decimal fraction may be left out.
Consider the fraction , in an digits representation.
This is a finite fraction: the error in the 8-digit representation is zero.
Find its binary representation, you know how to do it, but we will help you this time!
The last step is the same as the first, and so if we keep going, we'll end up with a repeating sequence of s:
Let's truncate it at the eighth digit:
This truncated binary fraction is not equal to , even though we started there:
The conversion resulted in an error of : small, but not negligible.
🔎 In modern computers, the truncation happens at -th or -th digit, the precision of single and double float variables. A digits truncation in the example before has an error equal to : extremely small, but still present.
The binary representation of a decimal fraction is exact only if is the sole prime factor of the denominator: , , and all have exact representations, on the other hand, or always have an error.
How to use our binary fraction converter?
You can use our binary fraction converters to convert from decimal fraction to binary and from binary fraction to decimal. Remember to pick the right one!
Select the number of digits you need in your representation. You won't be able to insert more than that number. The result will be truncated and not rounded!
Here's an example: select from binary to decimal, choose 4 digits, and input . The result is , or .
Did you notice that its denominator has a single prime factor, ? By inputting the number like that, we implicitly assumed that it was a finite binary fraction!
🙋 If you need a different number of digits than the one provided by our defaults, go in
advanced mode and insert the desired value. Remember to refresh the calculator if you want to use the default values again! 😀
Beyond 0s and 1s
We hope our binary fraction converter helped you in learning this not-so-straightforward topic. 🤞
We have many other binary calculators: try our binary arithmetic calculator, or the dedicated binary multiplication, binary addition, and many others! And if you need to review fractions, check our fraction to percent calculator, fraction exponent calculator, or equivalent fractions calculator. We covered almost everything!
Can all fractions be converted to binary?
Not all fractions can be exactly converted to binary: only if the denominator is a power of
2, the binary fraction will be finite. In every other case, there will be an error in the representation. The error's magnitude depends on the number of digits used to represent it.
How to convert fractions to binary?
Take a decimal fraction and start multiplying by two the decimal part. Every time the result is smaller than
1, add a
0 to the binary representation. If the result is greater or equal to
1, add a
1 to the binary representation and subtract
1 from the multiplication result. Proceed with multiplications until the result is
0 or you reach the desired amount of digits.
Learn more on how to represent fractions in binary on omnicalculator.com.
How do you represent 0.5 in binary?
0.5 × 2 = 1.0. Since the result is
1 to the binary fraction:
The remaining decimal part of the number is zero; thus, the representation is complete!
What is 0.1101 in decimal?
To convert from decimal to binary, you have to sum the negative powers of two corresponding to the positions of the
1s in the binary fraction.
In the case of
0.1101, you need to sum:
(1/2 × 1) + (1/4 × 1) + (1/8 × 0) + (1/16 × 1) = 13/16 = 0.8125.