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