EGRE 254 Number Systems and Codes 1/12/09 Digital Logic Design EGRE 254 Number Systems and Codes 1/12/09 11/20/2018
Positional Number Systems 11/20/2018 Positional Number Systems Numbers are commonly represented in the base 10 positional number system. For example 11/20/2018
In general (see page 26) A number D of radix or base r with p digits to the left of the radix point and n digits to the right of the radix point can be expressed as: di – in base 10 di – in base r 11/20/2018
11/20/2018 Examples 156.78 = (1x102 + 5x101 + 6x100 + 7x10-1 )8 = (1x82 + 5x81 + 6x80 + 7x8-1 )10 = (64 + 40 + 6 + .875)10 = 110.87510 559 = (5x101 + 5x100)9 = (5x91 + 5x90)10 = (45 + 5)10 = 5010 1212 = (1x121 + 2x120)10 = (12 + 2)10 = 1410 101100.112 = 101100.11 = 32+8+4+.5+.25 = 44.75 11/20/2018
Examples Does r10 = 10r ? Prove it! Does rb = br ? Prove it! 11/20/2018 Examples Does r10 = 10r ? Prove it! Does rb = br ? Prove it! 111b = 13310 Find b. (41/3)b = 13b Find b. (33/3)b = 11b Find b. 1. 10r = (1 x r1 + 0 x r0)10 = r10 2. Consider 23 = 210 = 102 != 112 3. 111b = 1xb2 + 1xb1 + 1 = b2 + b + 1 = 133 b2 + b - 132 = 0 (b-11)(b+12) = 0 b = 11, b = -12 (-12)2 + (-12) + 1 = 144 – 12 + 1 Note: (12)-12 = 1x(-12)1 + 2x(-12)0 = -12 + 2 = -10. Q. What is the advantage of a number system with a negative base? We don’t need the “-” sign. 4. 4b + 1 = 3(b+3) = 3b + 9 b= 9-1 = 8 5. 3b + 3 = 3(b + 1) = 3b + b ? |b| > 3 11/20/2018
Decimal (10) Binary (2) Octal (8) Hexadecimal (16) 1 2 10 3 11 4 100 5 1 2 10 3 11 4 100 5 101 6 110 7 111 8 1000 9 1001 1010 12 A 1011 13 B 1100 14 C 1101 15 D 1110 16 E 1111 17 F 11/20/2018
Example (5D4.A2)16 = (5x102+Dx101+4+Ax10-1+2x10-2)16 = (5x162+13x161+4+10x16-1+2x16-2)10 = (1280+208+4+.625+.0078125)10 = (1492.6328125)10 11/20/2018
How do we convert from base 10 to base r? We could use previous techniques, but we would have to do arithmetic in base r. Not desirable. Consider two cases. Integer number. Fractional number. 11/20/2018
Base 10 to base r (integer case) 11/20/2018
Example – Integer to Hex 1492 = (d3 d2 d1 d0)16 = d3x163+ d2x162+ d1x16+ d0 1492/16 = 93+4/16 = d3x162+ d2x16+ d1+ d0/16 d0 = 4 93 = d3x162+ d2x16+ d1 93/16 = 5 +13/16 = d3x16+ d2+ d1/16 d1 = 1310 = D16 5 = d3x16+ d2 5/16 = 0 + 5/16 = d3 + d2/16, d3 = 0, d2 = 5 149210 = 5D416 11/20/2018
In practice You may get mixed up on direction to read the answer. 5D416 or 4D516? Note that 5D4 = 0…05D4 4D5 not same as 4D50…0 11/20/2018
Example fraction to hex (.6328125)10 = (.d-1 d-2 d-3…)16 = (d-1x16-1+ d-2x16-2+ d-3x16-3+…)10 How do we find d-1? Multiply by 16. 16 x .6328125 = 10.125 = d-1+ d-2x16-1+ d-3x16-2+… d-1 = 10 and .125 = d-2x16-1+ d-3x16-2+… Multiply by 16. Then,.125 x 16 = 2.00 = d-2+ d-3x16-1+… d-2 = 2 and d-n = 0 for n > 2. Therefore, (.6328125)10 = (.A2)16 11/20/2018
Example For a number containing both an integer and a fractional part. Compute the two parts separately and combine. 1492.632812510 = 5D4.A216 11/20/2018
Special Case converting between base r and rn Convert 132.68 to binary. Could convert to decimal and then binary. Easier way. 11/20/2018
Examples Convert (11010.11)2 to octal, and to hexadecimal. 11/20/2018 Examples Convert (11010.11)2 to octal, and to hexadecimal. (11010.11)2 = (11,010.110)2 = 32.68 (11010.11)2 = (1,1010.1100)2 =1A.C16 Convert (121.121)3 to base 9 = 32. Convert (1234.567)8 to hexadecimal. Hint 8 = 23 and 16 = 24. (1234.567)8 = (001,010,011,100.101,110,111)2 = (0010 1001 1100.1011 1011 1000)2 = (29C.BB8)16 11/20/2018
11/20/2018