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:


1
21012,
p
ni
i
i rddddddD
2211001122 rdrdrdrdrdD
Decimal system:
base is 10,the digit may be 0 to 9
141031071011734 23
2101 10410310710134.17
Binary system:
base is 2,the digit may be 0 or 1
210122 212021202101.1 0 1
bit,one digit in binary system; MSB/LSB
Examples of positional number system
Binary numbers with certain width ;
The numbers always be set as 0.xxxxxxxx;
We can take these numbers as integers !
0 0 1 1 0 1 1 00 0 1 1 0 1 1 0.0?
Example for an 8-bit binary number:
Positional number system in
digital design
binary to decimal,based on definitions;
Examples,
1076432 2 1 0 9 3 7 5.022220 0 1 1 0 1 1 0.0
102 542416320 0 1 1 0 1 1 0
5422 1 0 9 3 7 5.0 8
Conversion:
from one system to another
binary to decimal Examples,
102?1 1 0 1.0 0 1 0?
102 45148320 0 1 0 1 1 0 1
1042 8 1 2 5.22/451 1 0 1.0 0 1 0
Conversion:
from one system to another
Conversion:
from Decimal to binary
For integer numbers,
divided by 2,get its remainders;
210 1 0 1 1 0 0 1 11 7 9?
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:
210 0 0 1 0 1 0 1 1.017.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
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 0
to 2n-1 !
A short way to represent numbers
Binary to octal,3-bit to one digit;
Binary to hexadecimal,4-bit to one digit;
Key point,divide from the radix point !
1682 85 6 1 3111 0 1 1 1 0 0 0 1 0 BB
1682,226.1 3 4 211.1 0 1 1 1 0 0 0 1 0 CE
Examples,
Conversion:
from one system to another
Summary,p.31 Table 2-2
Operations for unsigned numbers
Basic principles:
0+0=0 1+0=1 1+1=10 10-1=1
Addition and subtraction
C:carry S:sum B:borrow D:difference
Operations for unsigned numbers
Basic principles,0× A = 0 1× A = A
Multiplication
Shift-add,use adders and shift-registers;
The product width will be 2n !