0

I am studying a Computer Organization course, but in the slides it is mentioned that I have to convert fraction numbers to IEEE floating point representation. To do that first, I have to convert the irrational number to fractional representation, for example here are some common fraction approximations:

enter image description here

In the slide, they tried to explain how the fractional approximation of 1/3 was done, but I still didn't understand it:

enter image description here

How do I convert 1/3 to fractional approximation? I can't seem to find any method online?

Online User
  • 115
  • 8
  • First things first: do you know how to convert an integer in decimal form into binary? This is a slight extension of that method. – J. M. ain't a mathematician Jul 06 '16 at 13:34
  • Are you more interested in rational or irrational numbers? You say "irrational" in your question statement, but all of the numbers in your question are rational. (Remember: "rational" means a ratio of two integers. An irrational number is one that can't be written as a ratio of integers, like √2 or π.) – Michael Seifert Jul 06 '16 at 13:34
  • @MichaelSeifert: Rational numbers, sorry fixed question. – Online User Jul 06 '16 at 13:39
  • @J.M.: I know how to convert integer into binary. This method could work for some numbers but the method won't work on 1/3 since its decimal is non-ending 0.33333333333 – Online User Jul 06 '16 at 13:40
  • Hmm... If I multiply $1/3$ by $4$ and take the fractional part, I get $1/3$ again. This tells me that the repeating binary representation should resemble that of $1/4=0.01_2$. Get the idea? – J. M. ain't a mathematician Jul 06 '16 at 13:43

1 Answers1

1

This is just converting a decimal expression into a binary one. Take, for instance, $0.703125$. First, subtract off the largest power of $2$ that you can; in this case, $\frac{1}{2}$. Now you are left with $0.203125$. Now, the largest power of $2$ less than or equal to the number is $1/8 = 0.125$, and you get $0.078125$ left over. Repeat the process; we can subtract $1/16$ and then $1/64$, and then we are left with $0$. Therefore, $$0.703125_{10} = 0.101101_2 = \frac{1}{2}+\frac{1}{8}+\frac{1}{16}+\frac{1}{64}$$ With rational numbers whose denominator is a power of $2$, the process will eventually terminate. With other rational numbers, it will never terminate, but the pattern of 0's and 1's you get will be periodic. With irrational numbers, it will not be periodic. For the latter two cases, just perform this process to get however many digits you need (for IEEE 32-bit floating point numbers, I believe this number is 24 digits).

florence
  • 12,819