Professional Documents
Culture Documents
1
Lecture 1
2
Number Systems
3
Number Base Conversion
1310 = 11012
4
Number Base Conversion
11310 = 1618
5
Number Base Conversion
12610 = 7E16
6
Number Base Conversion
7
Number Base Conversion
20 2 10 0 0.8 2 1 0.6
10 2 5 0 0.6 2 1 0.2
5 2 2 1 0.2 2 0 0.4
2 2 1 0
20.3510 = 10100.0101102
1 2 0 1
8
Number Base Conversion
A3.5C16 = 163.35937510
9
Number Base Conversion
W 1 0 -1 -2
1. Multiply each digit by the
No 7 3 . 5 6
base raised to the power
of its weight Res 7* 3* 5*8-1 6* 8-2
81 80
2. Add the results obtained 56 3 0.62 0.093
in 1 above to get the 5 75
equivalent value in
decimal. 56+3+0.625+0.09375 = 59.71875
73.568 = 59.7187510
10
Number Base Conversion
Decimal Hexadecimal Binary
From Binary to Hexadecimal 0 0 0000
1. Starting at the binary 1 1 0001
point, group every four 2 2 0010
3 3 0011
binary bits into one 4 4 0100
group 5 5 0101
2. Convert each group into 6 6 0110
their hexadecimal 7 7 0111
8 8 1000
equivalent. 9 9 1001
Example 10 A 1010
11 B 1011
10 0100 1010.1100 10
12 C 1100
2 4 A . C 8 13 D 1101
14 E 1110
15 F 1111
11
Number Base Conversion
Decimal Hexadecimal Binary
From Hexadecimal to Binary 0 0 0000
1. Starting at the 1 1 0001
hexadecimal point, 2 2 0010
3 3 0011
convert each 4 4 0100
hexadecimal number into 5 5 0101
its equivalent four binary 6 6 0110
bits 7 7 0111
8 8 1000
Example 9 9 1001
10 A 1010
A F C . 3 B 11 B 1011
1010 1111 1100 . 0011 1011 12 C 1100
13 D 1101
14 E 1110
15 F 1111
12
Number Base Conversion
13
Number Base Conversion
6 3 2 . 3 1
110 011 010 . 011 001
14
Signed Numbers
15
Signed Numbers
Sign-Magnitude -7 is represented as
The MSB is the sign and the 10000111
rest is the absolute value of
the number
1s Complement 0 0 0 0 0 1 1 1
1 1 1 1 1 0 0 0
Each 0 in the positive
number is converted into 1
and each 1 into 0
2s Complement 0 0 0 0 0 1 1 1
Is obtained by adding 1 to 1 1 1 1 1 0 0 0
the 1s complement + 1
1 1 1 1 1 0 0 1
16
Summary
Binary Addition
1 + 0 + 0 = 01 Sum = 1, carry = 0
1 + 0 + 1 = 10 Sum = 0, carry = 1
1 + 1 + 0 = 10 Sum = 0, carry = 1
1 + 1 + 1 = 11 Sum = 1, carry = 1
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Summary
Binary Addition
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Summary
Binary Subtraction
Subtract the binary number 00111 from 10101 and show the
equivalent decimal subtraction.
1 1 1
10101
/ / / 21
00111 7
0 1 1 1 0 = 14
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Summary
Arithmetic Operations with Signed Numbers
Rules for addition: Add the two signed numbers. Discard any final carries. The
result is in signed form.
Examples:
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Summary
Arithmetic Operations with Signed Numbers
Note that if the number of bits required for the answer is exceeded,
overflow will occur. This occurs only if both numbers have the same sign.
The overflow will be indicated by an incorrect sign bit.
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Summary
Arithmetic Operations with Signed Numbers
Rules for subtraction: 2s complement the subtrahend and add the numbers.
Discard any final carries. The result is in signed form.
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Binary Codes
Summary
Decimal Binary BCD
BCD 0 0000 0000
1 0001 0001
Binary coded decimal (BCD) is a weighted 2 0010 0010
code that is commonly used in digital systems
3 0011 0011
when it is necessary to show decimal
4 0100 0100
numbers such as in clock displays.
5 0101 0101
6 0110 0110
7 0111 0111
The table illustrates the 8 1000 1000
difference between straight binary and 9 1001 1001
BCD. BCD represents each decimal digit 10 1010 0001 0000
with a 4-bit code. Notice that the codes 11 1011 0001 0001
1010 through 1111 are not used in BCD. 12 1100 0001 0010
13 1101 0001 0011
14 1110 0001 0100
15 1111 0001 0101
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Summary
8 3 5 4
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Summary
BCD
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Summary
Decimal Binary Gray code
Gray code 0 0000 0000
1 0001 0001
Gray code is an unweighted code that has a 2 0010 0011
single bit change between one code word and
3 0011 0010
the next in a sequence. Gray code is used to
4 0100 0110
avoid problems in systems where an error can
occur if more than one bit changes at a time. 5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Summary
Gray code
Binary sequence
Gray code sequence
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Decimal Binary Gray
0 0 0 0 0 0 0 0 0
1 0 0 0 1 0 0 0 1
2 0 0 1 0 0 0 1 1
3 0 0 1 1 0 0 1 0
4 0 1 0 0 0 1 1 0
5 0 1 0 1 0 1 1 1
6 0 1 1 0 0 1 0 1
7 0 1 1 1 0 1 0 0
8 1 0 0 0 1 1 0 0
9 1 0 0 1 1 1 0 1
10 1 0 1 0 1 1 1 1
11 1 0 1 1 1 1 1 0
12 1 1 0 0 1 0 1 0
13 1 1 0 1 1 0 1 1
14 1 1 1 0 1 0 0 1
15 1 1 1 1 1 0 0 0
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Binary-to-Gray Conversion
The MSB (Left-most) bit in both the binary and the Gray code are the same
Going from left to right, add each adjacent pair of binary code bits to get the
next Gray code bit. Discard carries
Example 1 + 0 1 1 0 Binary
1 1 1 0 1 Gray
Example 1 0 1 1 0
+ Gray
1 1 0 1 1
Binary
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Summary
ASCII
In 1981, IBM introduced extended ASCII, which is an 8-bit code and increased
the character set to 256. Other extended sets (such as Unicode) have been
introduced to handle characters in languages other than English.
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Summary
Parity Method
Floyd, Digital Fundamentals, 10th ed 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved