Chapter 2 Number systems and codes Positional number system representation and conversion Representations of negative numbers BCD codes and gray code
Chapter 2: Number systems and codes Positional number system : representation and conversion Representations of negative numbers BCD codes and Gray code
Positional number systems Use few digit to express infinite values Number: a string of digits; Each digit position has a different weight Definition: D=dddd,d D=d1×r2+d,r1+d1×p0+d,×r-1+d,×r-2
Positional number systems Use few digit to express infinite values Number: a string of digits; Each digit position has a different weight Definition: − =− − − = = 1 2 1 0 1 2 . p i n i i D d d d d d d r 2 2 1 1 0 0 1 1 2 2 − − − D = d r + d r + d r + d− r + d r
Examples of positional number system Decimal system: base is 10, the digit may be 0 to 9 1734=1×103+7×102+3×10+4×1 17.34=1×10+7×109+3×101+4×102 Binary system base is 2, the digit may be 0 or 1 101.01=1.22+0.21+1.20+0.2-1+1.22 bit: one digit in binary system; MSB/LSB
Decimal system: base is 10, the digit may be 0 to 9 1734 1 10 7 10 3 10 4 1 3 2 = + + + 1 0 1 2 17.34 1 10 7 10 3 10 4 10 − − = + + + Binary system: base is 2, the digit may be 0 or 1 2 1 0 1 2 101.012 1 2 0 2 1 2 0 2 1 2 − − = + + + + bit: one digit in binary system; MSB/LSB Examples of positional number system
Positional number system in digital design Binary numbers with certain width i The numbers always be set as 0.XXXXXXXX, We can take these numbers as integers t Example for an 8-bit binary number. 0.00110110→00110110
Binary numbers with certain width ; The numbers always be set as 0.xxxxxxxx; We can take these numbers as integers ! 0.0011011000110110 Example for an 8-bit binary number: Positional number system in digital design
Conversion. from one system to another binary to decimal: based on definitions; Examples 001101102=32+16+4+2=540 0.00110110=23+2-4+26+2-7=0.2109375 0.2109375×28=54
binary to decimal: based on definitions; Examples : 1 0 3 4 6 7 0.001101102 = 2 + 2 + 2 + 2 = 0.2109375 − − − − 001101102 = 32+16+ 4+ 2 = 5410 0.2109375 2 54 8 = Conversion: from one system to another
Conversion: from one system to another binary to decimal Examples 0010.1101,=? 001011012=32+8+4+1=450 0010.11012=45/2=281250
binary to decimal Examples : 2 10 0010.1101 = ? 001011012 = 32+8+ 4+1= 4510 1 0 4 0010.11012 = 45/ 2 = 2.8125 Conversion: from one system to another
Conversion from Decimal to binary For integer numbers divided by 2, get its remainders Examples for 8-bit binary numbers 1791=10110011 1798944-22—11-5-2—1 11001101
Conversion: from Decimal to binary For integer numbers : divided by 2, get its remainders; 17910 =101100112 Examples for 8-bit binary numbers: 179—89 —44—22—11—5—2—1 1 1 0 0 1 1 0 1
Conversion from Decimal to binary For decimal fraction numbers multiplied by radix, and get its integers; Examples for 8-bit binary numbers 0.1710=0.001010112 0.17—0.340.68—1.360.721.440.881761.52
Conversion: from Decimal to binary For decimal fraction numbers : multiplied by radix, and get its integers; Examples for 8-bit binary numbers: 10 001010112 0.17 = 0. 0.17—0.34 —0.68—1.36—0.72—1.44—0.88—1.76—1.52
Different number systems P 28 Table 2-1 Binary Decimal Octal 3-bit string Hexadecimal 4-bit string 0o1 010 0010 0011 100 100 0100 101 101 6 6 l10 0110 111 111 0111 1000 10 8 1000 1001 l001 10 12 1010 1011 B l011 1100 12 14 1100 1101 15 1101 l110 14 16 E 1110 1111 15 17 1111
Different number systems P.28 Table 2-1
Different number systems Binary numbers in digital design always be take as integers; n-bit binary string may have 2n different forms, and will represent numbers from o to 2n-1!
Different number systems Binary numbers in digital design always be take as integers; n-bit binary string may have 2 n different forms , and will represent numbers from 0 to 2 n -1 !