How do you convert a fraction to binary?

后端 未结 5 1594
野性不改
野性不改 2020-11-30 17:42

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

How do I do that? Am I supposed to convert to binary and then divide? Could someone show me?

5条回答
  •  北海茫月
    2020-11-30 17:59

    Took me a while to understand @Femaref ('s) answer so thought I would elaborate.

    Elboration

    You want to convert decimal 1/10 which equal 0.1 to binary. Start with 0.1 as your input and follow these steps:

    1. Multiply input by 2 (mult column)
    2. Take decimal from answer (answer column) as the digit (binary column)
    3. Take the fraction (fraction column) as the input for the next step
    4. Repeat steps 1, 2 and 3 until you either get to 0 or a periodic number. The start of periodic number in this case is shown in last column so we can stop there. But I continued to show the repetition for clarity.
    5. The answer is the numbers taken from the 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 |                      |
    +-------+-------+--------+---------+----------+--------+----------------------+
    

提交回复
热议问题