How do you convert a fraction to binary?

1/10(decimal) = 0.0001100110011... (binary)

How should I do it? Should I convert to binary and then split? Can someone show me?

+49
binary
Feb 13 2018-11-21T00:
source share
5 answers

At university, I found out this way:

  • Multiply by two
  • accept decimal as a digit
  • take the fraction as a starting point for the next step
  • repeat until you go to 0 or to the periodic number
  • read the number starting at the top - the first result is the first digit after the decimal point

Example:

 0.1 * 2 = 0.2 -> 0 0.2 * 2 = 0.4 -> 0 0.4 * 2 = 0.8 -> 0 0.8 * 2 = 1.6 -> 1 0.6 * 2 = 1.2 -> 1 0.2 * 2 = 0.4 -> 0 0.4 * 2 = 0.8 -> 0 0.8 * 2 = 1.6 -> 1 0.6 * 2 = 1.2 -> 1 Result: 0.00011(0011) periodic. 
+78
Feb 13 2018-11-22T00:
source share
— -
  eleven
 - (dec) = ---- (bin)
 10 1010


        0.000110011 ...
       -------------
 1010 |  1.0000000000
          1010
        ------
          01100
           1010
          -----
           0010000
              1010
             -----
              01100
               1010
              -----
               0010
+17
Feb 13 '11 at 10:12
source share

This may be somewhat confusing, but the decimal positions in the binary representation will be the inverse forces of the two (e.g. 1/2, 1/4, 1/8, 1/16, for the first, second, third and fourth decimal places, respectively) , as in decimal, decimal numbers are inverse consecutive powers of ten.

To answer your question, you will need to figure out what mutual powers of the two must be added to add up to 1/10. For example:

1/16 + 1/32 = 0.099375, which is pretty close to 1/10. Adding 1/64 puts us, like 1/128. But 1/256 brings us closer. So:

0.00011001 binary = 0.09765625 decimal, which is close to what you requested.

You can continue to add more numbers, so the answer will be 0.00011001 ...

+13
Feb 13 '11 at 10:01
source share

Here's how to think about the method.

Each time you multiply by 2, you change the binary representation of the number left by 1 place. You have moved the highest digit after the point to 1st place, so remove this number, and this is the first (highest, therefore the most left) digit of your fraction. Do it again and you will have the next digit.

Converting the base of an integer by dividing and taking the remainder, since the next digit shifts the number to the right. That's why you get the numbers in the reverse order, first the lowest.

This, obviously, can be generalized to any base, and not just 2, as indicated by GoofyBall .

One more thing to think about: if you round to N digits, stop at N + 1 digits. If the digit # N + 1 is one, you need to round (since binary numbers can only be 0 or 1, trimming the next digit, and 1 is just as inaccurate as truncating 5 to decimal).

+6
Apr 28 '15 at 11:38
source share

It took a while to figure out the answer of @Femaref (s), so I thought that I would understand in detail.

Elboration

You want to convert decimal to 1/10 , which is 0.1 binary. Start with 0.1 as your input and do the following:

  • Multiply input by 2 (many columns)
  • Take decimal value from answer (response column) as a digit (binary column)
  • Take the fraction (fraction fraction) as input for the next step
  • Repeat steps 1, 2, and 3 until you reach 0 or the periodic number. The beginning of the periodic number in this case is shown in the last column, so we can stop there. But I continued to demonstrate repetition for clarity.
  • The answer is numbers taken from a binary column starting at the top.

In this case, it is:

 0.00011(0011) Note: numbers within parenthesis will keep repeating (periodic) 



 +-------+-------+--------+---------+----------+--------+----------------------+ | input | mult | answer | decimal | fraction | binary | | +-------+-------+--------+---------+----------+--------+----------------------+ | 0.1 | 2 | 0.2 | 0 | .2 | 0 | | | 0.2 | 2 | 0.4 | 0 | .4 | 0 | | | 0.4 | 2 | 0.8 | 0 | .8 | 0 | | | 0.8 | 2 | 1.6 | 1 | .6 | 1 | | | 0.6 | 2 | 1.2 | 1 | .2 | 1 | | | 0.2 | 2 | 0.4 | 0 | .4 | 0 | | | 0.4 | 2 | 0.8 | 0 | .8 | 0 | | | 0.8 | 2 | 1.6 | 1 | .6 | 1 | | | 0.6 | 2 | 1.2 | 1 | .2 | 1 | < Repeats after this | | 0.2 | 2 | 0.4 | 0 | .4 | 0 | | | 0.4 | 2 | 0.8 | 0 | .8 | 0 | | | 0.8 | 2 | 1.6 | 1 | .6 | 1 | | | 0.6 | 2 | 1.2 | 1 | .2 | 1 | | +-------+-------+--------+---------+----------+--------+----------------------+ 
+2
May 13 '17 at 14:41
source share



All Articles