After I've made several calculators for numeral systems conversion (from the simplest one to more advanced: Conversion of decimal number to other notations, Conversion from decimal numeral system, Conversion between any bases - users often asked me, what should we do about fractional numbers, how to convert them?
web developer and programmer tools
So, I decided to make another calculator, which can also convert fractional numbers between different numeral systems.
As usual, I've placed some theory below the calculator
So, I used to think that conversion of fractional numbers is difficult question, but it turns to be quite easy to understand. All we need to remember is that we deal with positional numeral system.
Let me show it on example.
Take a look at decimal number 6.125. You can write it like this:
Easy to follow, isn't it?
But it is the same thing for any other positional numeral system. Let's take, for example, infamous binary system, and fractional binary number 110.001. You can write it like this:
Yes, I've made it up.
Binary 110.001 is decimal 6.125. Shouldn't that easy?
But, there is one caveat. Since we have fractions, and the denominators are different, we can't always keep the same precision with different numeral systems.
Again, let me show it on example.
How to convert decimal to binary
Take a look at decimal number 0.8
Everything is nice... for decimal numeral system.
Decimal Fraction to Binary Conversion
But for binary numeral system we have a problems. Look at this
We can go on, but even now we can see that decimal 0.8 is binary 0.11001100...(and many digits).
In fact, it is periodic number with period 1100, so we won't find the exact number of binary digits to write 0.8 precisely.
It is 1100 all the way down.
That's why conversion of fractional numbers often gives us conversion error. The error depends on number of digits after point which we decide to use. For example, let's convert decimal 0.8 to binary and use 6 digits after the point. We will get 0.110011.
But it is not decimal 0.8, in fact, it is decimal 0.796875, the difference is 0.003125. And this is our error during conversion decimal 0.8 to binary with 6 digits after the point.
The value of rightmost digit is called resolution or precision, and defines the smallest possible nonzero number which can be written using this number of digits.
Conversion of decimals to binary numbers
For our example it is . And maximum possible conversion error in that case is one-half of it, or 0.0078125. Note that our conversion error for 0.8 is not that bad comparing to maximum possible error.
Source number (decimal)
Target number (decimal)
Conversion error (decimal)
Maximum conversion error possible (decimal)
Conversion of fractional numbers between numeral systems
Digits after the decimal point: 8