Binry Representtion of Numbers Autr Kw After reding this chpter, you should be ble to: 1. convert bse- rel number to its binry representtion,. convert binry number to n equivlent bse- number. In everydy life, we use number system with bse of. For exmple, look t the number 57.56. Ech digit in 57.56 hs vlue of 0 through 9 nd hs plce vlue. It cn be written s 57.76= + 5 1 + 7 0 + 7 + 6 In binry system, we hve similr system where the bse is mde of only two digits 0 nd 1. So it is bse system. A number like (11.0011) in bse- represents the deciml number s 3 1 0 ((1 + 0 + 1 + 1 ) + (0 + 0 + 1 + 1 )) ( 11.0011) = = 11.1875 in the deciml system. To understnd the binry system, we need to be ble to convert binry numbers to deciml numbers nd vice-vers. We hve lredy seen n exmple of how binry numbers re converted to deciml numbers. Let us see how we cn convert deciml number to binry number. For exmple tke the deciml number 11.1875. First, look t the integer prt: 11. 1. Divide 11 by. This gives quotient of 5 nd reminder of 1. Since the reminder is 1, 0 = 1.. Divide the quotient 5 by. This gives quotient of nd reminder of 1. Since the reminder is 1, 1 = 1. 3. Divide the quotient by. This gives quotient of 1 nd reminder of 0. Since the reminder is 0, = 0. 4. Divide the quotient 1 by. This gives quotient of 0 nd reminder of 1. Since the reminder is, 1. 3 = Sylor URL: http://www.sylor.org/courses/me05/ Pge 1 of 1
Since the quotient now is 0, the process is stopped. The bove steps re summrized in Tble 1. Sylor URL: http://www.sylor.org/courses/me05/ Pge of 1
Tble 1 Converting bse- integer to binry representtion. Quotient Reminder 11/ 5 1= 0 5/ 1= 1 / 1 0= 1/ 0 1= 3 Hence (11) = ( 3 = (11) 1 0 ) For ny integer, the lgorithm for finding the binry equivlent is given in the flow chrt on the next pge. Now let us look t the deciml prt, tht is, 0.1875. 1. Multiply 0.1875 by. This gives 0.375. The number before the deciml is 0 nd the number fter the deciml is 0.375. Since the number before the deciml is 0, =0.. Multiply the number fter the deciml, tht is, 0.375 by. This gives 0.75. The number before the deciml is 0 nd the number fter the deciml is 0.75. Since the number before the deciml is 0, = 0. 3. Multiply the number fter the deciml, tht is, 0.75 by. This gives 1.5. The number before the deciml is 1 nd the number fter the deciml is 0.5. Since the number before the deciml is 1, = 1. 4. Multiply the number fter the deciml, tht is, 0.5 by. This gives 1.0. The number before the deciml is 1 nd the number fter the deciml is 0. Since the number before the deciml is 1, = 1. Since the number fter the deciml is 0, the conversion is complete. The bove steps re summrized in Tble. Tble. Converting bse- frction to binry representtion. Sylor URL: http://www.sylor.org/courses/me05/ Pge 3 of 1
Number Number fter deciml Number before deciml 0.1875 0.375 0.375 0= 0.375 0.75 0.75 0= 0.75 1.5 0.5 1= 0.5 1.0 0.0 1= Sylor URL: http://www.sylor.org/courses/me05/ Pge 4 of 1
Strt Input (N) Integer N to be converted to binry formt i = 0 Divide N by to get quotient Q & reminder R i = i+1 i = R No Is Q = 0? Yes n = i (N) = (... ) Sylor URL: http://www.sylor.org/courses/me05/ STOP Pge 5 of 1
Hence (0.1875) ( = = (0.0011) ) The lgorithm for ny frction is given in flowchrt on the next pge. Hving clculted nd we hve ( 11) = (11 ) ( 0.1875) = (0.0011, ) ( 11.1875) = (11.0011. ) In the bove exmple, when we were converting the frctionl prt of the number, we were left with 0 fter the deciml number nd used tht s plce to stop. In mny cses, we re never left with 0 fter the deciml number. For exmple, finding the binry equivlent of 0.3 is summrized in Tble 3. Tble 3. Converting bse- frction to pproximte binry representtion. Number Number fter deciml Number before deciml 0.3 0.6 0.6 0= 0.6 1. 0. 1= 0. 0.4 0.4 0= Sylor URL: http://www.sylor.org/courses/me05/ Pge 6 of 1
0.4 0.8 0.8 0= 0.8 1.6 0.6 1= 5 As you cn see the process will never end. In this cse, the number cn only be pproximted in binry formt, tht is, ( 0.3) = ( 5) (0.001) Q: But wht is the mthemtics behinds this process of converting deciml number to binry formt? A: Let z be the deciml number written s where z = x. y x is the integer prt nd y is the frctionl prt. We wnt to find the binry equivlent of x. So we cn write Sylor URL: http://www.sylor.org/courses/me05/ Pge 7 of 1
Strt Input (F) Frction F to be converted to binry formt i= Multiply F by to get number before deciml, S nd fter deciml, T i= i i = R No Is T = 0? Yes n = i (F) = (... ) Sylor URL: http://www.sylor.org/courses/me05/ STOP Pge 8 of 1
x= n n 0 n + n 1 +... + 0 If we cn now find 0,..., in the bove eqution then n ( x) = ( nn 1... 0) We now wnt to find the binry equivlent of y. So we cn write y= b + b +... b If we cn now find 1 + m ( y) = ( b 1b... b m) m m b 1,..., b in the bove eqution then Let us look t this using the sme exmple s before. Exmple 1 Convert ( 11.1875) to bse. Solution To convert ( 11) to bse, wht is the highest power of tht is prt of 11. Tht power is 3, s 3 = 8 to give 11= 3 + 3 Wht is the highest power of tht is prt of 3. Tht power is 1, s 1 = to give So 3= 11= 1 + 3 1 + 3= 3 + 1 + 1 Wht is the highest power of tht is prt of 1. Tht power is 0, s 0 = 1 to give Hence 0 1= Sylor URL: http://www.sylor.org/courses/me05/ Pge 9 of 1
( 11) = 3 1 3 1 0 3 1 0 = + + 1= + + = 1 + 0 + 1 + 1 (11) To convert ( 0.1875) to the bse, we proceed s follows. Wht is the smllest negtive power of tht is less thn or equl to 0.1875. Tht power is 3 s 3 =0.15. So 0.1875= + 0.065 Wht is the next smllest negtive power of tht is less thn or equl to 0.065. Tht power is 4 s =0. 065. So Hence Since nd we get 0.1875= 3 + ( 0.1875) = ( 11) = (11 = + 0.065= + = 0 + 0 + 1 + 1 (0.0011) ) ( 0.1875) = (0.0011 ) ( 11.1875) = (11.0011 ) Cn you show this lgebriclly for ny generl number? Exmple Convert ( 13.875) to bse. Solution For ( 13), conversion to binry formt is shown in Tble 4. Sylor URL: http://www.sylor.org/courses/me05/ Pge of 1
Tble 4. Conversion of bse- integer to binry formt. Quotient Reminder 13/ 6 1= 0 6/ 3 0= 1 3/ 1 1= 1/ 0 1= 3 So ( 13) = (11. ) Conversion of ( 0.875) to binry formt is shown in Tble 5. Tble 5. Converting bse- frction to binry representtion. Number Number fter deciml Number before deciml 0.875 1.75 0.75 1= 0.75 1.5 0.5 1= 0.5 1.0 0.0 1= So ( 0.875) = (0.111 ) Sylor URL: http://www.sylor.org/courses/me05/ Pge 11 of 1
Hence ( 13.875) = (11.111 ) Sylor URL: http://www.sylor.org/courses/me05/ Pge 1 of 1