Converting to BinaryDate: 05/27/2001 at 05:31:17 From: maya karipel Subject: Binary numbers Dear sir, I would like to know how to convert the number .78125 to its binary equivalent. Thanking you, Yours faithfully, Maya A.Karipel Date: 06/05/2001 at 15:06:30 From: Doctor Twe Subject: Re: Binary numbers Hi Maya - thanks for writing to Dr. Math. To convert a whole number into binary you can repeatedly divide by 2, keeping the remainders. See for example, Converting Binary to and From Decimal http://mathforum.org/dr.math/problems/shroff.6.16.99.html To convert a fraction into binary, we can repeatedly multiply by 2, keeping the integer part. After each multiplication, the integer part becomes the next binary digit (left to right), and the fractional part gets multiplied by 2 again. We can continue until the fractional part is zero, or until we have as many digits as we desire. For example, to convert 0.59375 (base 10) into binary we multiply: .1 0 0 1 1 / / / / / .59375 * 2 = 1.1875 keep the 1 -----------+ / / / / \__/ / / / / /------------/ / / / / v / / / / .1875 * 2 = 0.375 keep the 0 ---------+ / / / \_/ / / / /-----------/ / / / v / / / .375 * 2 = 0.75 keep the 0 -------+ / / \/ / / /-----------/ / / v / / .75 * 2 = 1.5 keep the 1 -----+ / \/ / /------------/ / v / .5 * 2 = 1.0 keep the 1 ---+ Since the fractional part of the last multiplication is 0, we can stop and we have an exact answer. (Any additional digits would simply be 0.) So our answer is 0.59375 (base 10) = 0.010011 (base 2). We can check this by converting the binary back to decimal. The fractional place values in binary are: 1 1 1 1 1 . --- --- --- --- --- ... 2^1 2^2 2^3 2^4 2^5 or: 1 1 1 1 1 . - - - -- -- ... 2 4 8 16 32 or: . (.5) (.25) (.125) (.0625) (.03125) ... So 0.10011 (base 2) is: 1 * .5 = .5 + 0 * .25 = .0 + 0 * .125 = .0 + 1 * .0625 = .0625 + 1 * .03125 = .03125 -------- .59375 (base 10) So it double-checks. Notice that most fractions that terminate in a decimal will be repeating fractions in binary. For example, let's convert the fraction 0.6 (base 10) to binary: .1 0 0 1 1 0 0 1 ... / / / / / / / / .6 * 2 = 1.2 keep the 1 ---+ / / / / / / / .2 * 2 = 0.4 keep the 0 ----+ / / / / / / .4 * 2 = 0.8 keep the 0 -----+ / / / / / .8 * 2 = 1.6 keep the 1 ------+ / / / / .6 * 2 = 1.2 keep the 1 -------+ / / / .2 * 2 = 0.4 keep the 0 --------+ / / .4 * 2 = 0.8 keep the 0 ---------+ / .8 * 2 = 1.6 keep the 1 ----------+ Notice that the second four lines repeat the first four, and the next four would repeat them, and so on. Thus, our answer is: 0.6 (base 10) = 0.10011001... (base 2) For some more general information on converting fractions to other bases, check out: Fraction/Decimal Conversion to Other Bases http://mathforum.org/dr.math/problems/trinidad8.12.98.html For information on how computers represent fractions in binary, see: Floating-Point Binary Fractions http://mathforum.org/dr.math/problems/mairaj.7.19.99.html both from our Ask Dr. Math archives. I hope this helps. If you have any more questions, write back. - Doctor TWE, The Math Forum http://mathforum.org/dr.math/ |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994- The Math Forum at NCTM. All rights reserved.
http://mathforum.org/dr.math/