2 Number Systems Floyd
-
Upload
arkie-baja -
Category
Documents
-
view
224 -
download
0
Transcript of 2 Number Systems Floyd
-
8/12/2019 2 Number Systems Floyd
1/91
-
8/12/2019 2 Number Systems Floyd
2/91
-
8/12/2019 2 Number Systems Floyd
3/91
-
8/12/2019 2 Number Systems Floyd
4/91
-
8/12/2019 2 Number Systems Floyd
5/91
-
8/12/2019 2 Number Systems Floyd
6/91
-
8/12/2019 2 Number Systems Floyd
7/91
-
8/12/2019 2 Number Systems Floyd
8/91
-
8/12/2019 2 Number Systems Floyd
9/91
-
8/12/2019 2 Number Systems Floyd
10/91
-
8/12/2019 2 Number Systems Floyd
11/91
-
8/12/2019 2 Number Systems Floyd
12/91
-
8/12/2019 2 Number Systems Floyd
13/91
-
8/12/2019 2 Number Systems Floyd
14/91
-
8/12/2019 2 Number Systems Floyd
15/91
-
8/12/2019 2 Number Systems Floyd
16/91
-
8/12/2019 2 Number Systems Floyd
17/91
-
8/12/2019 2 Number Systems Floyd
18/91
-
8/12/2019 2 Number Systems Floyd
19/91
-
8/12/2019 2 Number Systems Floyd
20/91
-
8/12/2019 2 Number Systems Floyd
21/91
-
8/12/2019 2 Number Systems Floyd
22/91
-
8/12/2019 2 Number Systems Floyd
23/91
-
8/12/2019 2 Number Systems Floyd
24/91
-
8/12/2019 2 Number Systems Floyd
25/91
-
8/12/2019 2 Number Systems Floyd
26/91
-
8/12/2019 2 Number Systems Floyd
27/91
-
8/12/2019 2 Number Systems Floyd
28/91
-
8/12/2019 2 Number Systems Floyd
29/91
-
8/12/2019 2 Number Systems Floyd
30/91
-
8/12/2019 2 Number Systems Floyd
31/91
-
8/12/2019 2 Number Systems Floyd
32/91
-
8/12/2019 2 Number Systems Floyd
33/91
2009 Pearson Education
Octal to Binary
Hexadecimal
Decimal Octal
Binary
-
8/12/2019 2 Number Systems Floyd
34/91
2009 Pearson Education
Octal to Binary
Technique Convert each octal digit to a 3-bit equivalent
binary representation
-
8/12/2019 2 Number Systems Floyd
35/91
2009 Pearson Education
Example
705 8 = ? 2
7 0 5
111 000 101
705 8 = 111000101 2
-
8/12/2019 2 Number Systems Floyd
36/91
2009 Pearson Education
Hexadecimal to Binary
Hexadecimal
Decimal Octal
Binary
-
8/12/2019 2 Number Systems Floyd
37/91
2009 Pearson Education
Hexadecimal to Binary
Technique Convert each hexadecimal digit to a 4-bit
equivalent binary representation
-
8/12/2019 2 Number Systems Floyd
38/91
2009 Pearson Education
Example
10AF 16 = ? 2
1 0 A F
0001 0000 1010 1111
10AF 16 = 0001000010101111 2
-
8/12/2019 2 Number Systems Floyd
39/91
2009 Pearson Education
Decimal to Octal
Hexadecimal
Decimal Octal
Binary
-
8/12/2019 2 Number Systems Floyd
40/91
2009 Pearson Education
Decimal to Octal
Technique Divide by 8 Keep track of the remainder
-
8/12/2019 2 Number Systems Floyd
41/91
2009 Pearson Education
Example
1234 10 = ? 8
8 1234
154 28
19 28
2 38
0 2
1234 10 = 2322 8
-
8/12/2019 2 Number Systems Floyd
42/91
2009 Pearson Education
Decimal to Hexadecimal
Hexadecimal
Decimal Octal
Binary
-
8/12/2019 2 Number Systems Floyd
43/91
2009 Pearson Education
Decimal to Hexadecimal
Technique Divide by 16 Keep track of the remainder
-
8/12/2019 2 Number Systems Floyd
44/91
2009 Pearson Education
Example
1234 10 = ? 16
1234 10 = 4D2 16
16 1234
77 216
4 13 = D160 4
-
8/12/2019 2 Number Systems Floyd
45/91
2009 Pearson Education
Binary to Octal
Hexadecimal
Decimal Octal
Binary
-
8/12/2019 2 Number Systems Floyd
46/91
2009 Pearson Education
Binary to Octal
Technique Group bits in threes, starting on right Convert to octal digits
-
8/12/2019 2 Number Systems Floyd
47/91
2009 Pearson Education
Example
10110101112
= ?8
1 011 010 111
1 3 2 7
1011010111 2 = 1327 8
-
8/12/2019 2 Number Systems Floyd
48/91
2009 Pearson Education
Binary to Hexadecimal
Hexadecimal
Decimal Octal
Binary
-
8/12/2019 2 Number Systems Floyd
49/91
2009 Pearson Education
Binary to Hexadecimal
Technique Group bits in fours, starting on right Convert to hexadecimal digits
-
8/12/2019 2 Number Systems Floyd
50/91
2009 Pearson Education
Example
10101110112
= ?16
10 1011 1011
2 B B
1010111011 2 = 2BB 16
-
8/12/2019 2 Number Systems Floyd
51/91
2009 Pearson Education
Octal to Hexadecimal
Hexadecimal
Decimal Octal
Binary
-
8/12/2019 2 Number Systems Floyd
52/91
2009 Pearson Education
Octal to Hexadecimal
Technique Use binary as an intermediary
-
8/12/2019 2 Number Systems Floyd
53/91
2009 Pearson Education
Example
10768
= ?16
1 0 7 6
001 000 111 110
2 3 E
1076 8 = 23E 16
-
8/12/2019 2 Number Systems Floyd
54/91
2009 Pearson Education
Hexadecimal to Octal
Hexadecimal
Decimal Octal
Binary
-
8/12/2019 2 Number Systems Floyd
55/91
2009 Pearson Education
Hexadecimal to Octal
Technique Use binary as an intermediary
-
8/12/2019 2 Number Systems Floyd
56/91
2009 Pearson Education
Example
1F0C16
= ?8
1 F 0 C
0001 1111 0000 1100
1 7 4 1 4
1F0C 16 = 17414 8
-
8/12/2019 2 Number Systems Floyd
57/91
2009 Pearson Education
Exercise Convert ...
Dont use a calculator!
Decimal Binary OctalHexa-
decimal
33
1110101703
1AF
Skip answer Answer
C
-
8/12/2019 2 Number Systems Floyd
58/91
2009 Pearson Education
Exercise Convert
Decimal Binary OctalHexa-
decimal
33 100001 41 21
117 1110101 165 75451 11100001
1703 1C3
431 110101111
657 1AF
Answer
-
8/12/2019 2 Number Systems Floyd
59/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
1s Complement
The 1s complement of a binary number is just the inverseof the digits. To form the 1s complement, change all 0s to1s and all 1s to 0s.For example, the 1s complement of 11001010 is
00110101
In digital circuits, the 1s complement is formed by usinginverters: 1 1 0 0 1 0 1 0
0 0 1 1 0 1 0 1
-
8/12/2019 2 Number Systems Floyd
60/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
2s Complement
The 2s complement of a binary number is found byadding 1 to the LSB of the 1s complement.
Recall that the 1s complement of 11001010 is00110101 (1s complement)
To form the 2s complement, add 1: +100110110 (2s complement)
Adder
Input bits
Output bits (sum)
Carryin (add 1)
1 1 0 0 1 0 1 0
0 0 1 1 0 1 0 1
1
0 0 1 1 0 1 1 0
-
8/12/2019 2 Number Systems Floyd
61/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
Signed Binary Numbers
There are several ways to represent signed binary numbers.In all cases, the MSB in a signed number is the sign bit, thattells you if the number is positive or negative.
Computers use a modified 2s complement forsigned numbers. Positive numbers are stored in true form(with a 0 for the sign bit) and negative numbers are storedin complement form (with a 1 for the sign bit).
For example, the positive number 58 is written using 8-bits as00111010 (true form).
Sign bit Magnitude bits
-
8/12/2019 2 Number Systems Floyd
62/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
Signed Binary Numbers
Assuming that the sign bit = - 128, show that 11000110 = - 58
as a 2s complement signed number:
1 1 0 0 0 1 1 0Column weights: - 128 64 32 16 8 4 2 1 .
- 128 +64 +4 +2 = - 58
Negative numbers are written as the 2s complement of thecorresponding positive number.
- 58 = 11000110 (complement form)
Sign bit Magnitude bitsAn easy way to read a signed number that uses this notation is toassign the sign bit a column weight of - 128 (for an 8-bit number).Then add the column weights for the 1s.
The negative number - 58 is written as:
-
8/12/2019 2 Number Systems Floyd
63/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
Floating Point Numbers
Express the speed of light, c, in single precision floating pointnotation. ( c = 0.2998 x 10 9)
Floating point notation is capable of representing verylarge or small numbers by using a form of scientificnotation. A 32-bit single precision number is illustrated.
S E (8 bits) F (23 bits)
Sign bit Magnitude with MSB droppedBiased exponent (+127)
In scientific notation, c = 1 .001 1101 1110 1001 0101 1100 0000 x 228.
0 10011011 001 1101 1110 1001 0101 1100
In binary, c = 0001 0001 1101 1110 1001 0101 1100 0000 2.
S = 0 because the number is positive. E = 28 + 127 = 155 10 = 1001 1011 2.F is the next 23 bits after the first 1 is dropped. In floating point notation, c =
-
8/12/2019 2 Number Systems Floyd
64/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
Arithmetic Operations with Signed Numbers
Using the signed number notation with negativenumbers in 2s complement form simplifies additionand subtraction of signed numbers.
Rules for addition : Add the two signed numbers. Discardany final carries. The result is in signed form.Examples:
00011110 = +30 00001111 = +15
00101101 = +45
00001110 = +14 11101111 = - 17
11111101 =-
3
11111111 = - 1 11111000 = - 8
11110111 =-
91Discard carry
-
8/12/2019 2 Number Systems Floyd
65/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
Arithmetic Operations with Signed Numbers
01000000 = +128 01000001 = +129
10000001 =-
126
10000001 = - 127 10000001 = - 127
100000010 = +2
Note that if the number of bits required for the answer isexceeded, overflow will occur. This occurs only if bothnumbers have the same sign. The overflow will beindicated by an incorrect sign bit.
Two examples are:
Wrong! The answer is incorrectand the sign bit has changed.
Discard carry
-
8/12/2019 2 Number Systems Floyd
66/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
Arithmetic Operations with Signed Numbers
Rules for subtraction : 2s complement the subtrahend andadd the numbers. Discard any final carries. The result is insigned form.
00001111 = +151
Discard carry
2s complement subtrahend and add: 00011110 = +30
11110001 = - 15
Repeat the examples done previously, but subtract:0001111000001111-
0000111011101111
1111111111111000- -
00011111 = +31
00001110 = +14
00010001 = +1700000111 = +71
Discard carry
11111111 = - 1
00001000 = + 8
(+30) (+15)
(+14) (- 17)
(- 1) (- 8)
-
8/12/2019 2 Number Systems Floyd
67/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
Hexadecimal Numbers
Hexadecimal uses sixteen characters torepresent numbers: the numbers 0through 9 and the alphabetic charactersA through F.
0
12345
6789101112131415
0
12345
6789ABCDEF
0000
00010010001101000101
0110011110001001101010111100110111101111
Decimal Hexadecimal Binary
Large binary number can easily be converted to hexadecimal bygrouping bits 4 at a time and writingthe equivalent hexadecimal character.
Express 1001 0110 0000 1110 2 inhexadecimal:
Group the binary number by 4-bitsstarting from the right. Thus, 960E
-
8/12/2019 2 Number Systems Floyd
68/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
Hexadecimal Numbers
Hexadecimal is a weighted numbersystem. The column weights are
powers of 16, which increase fromright to left.
.
1 A 2 F 16
6703 10
Column weights 163 16 2 16 1 16 0
4096 256 16 1 .{
Express 1A2F 16 in decimal.
Start by writing the column weights:4096 256 16 1
1(4096) + 10(256) +2(16) +15(1) =
0
12345
6789101112131415
0
12345
6789ABCDEF
0000
00010010001101000101
0110011110001001101010111100110111101111
Decimal Hexadecimal Binary
-
8/12/2019 2 Number Systems Floyd
69/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
Octal Numbers
Octal uses eight characters the numbers0 through 7 to represent numbers.There is no 8 or 9 character in octal.
0
12345
6789101112131415
0
12345
671011121314151617
0000
00010010001101000101
0110011110001001101010111100110111101111
Decimal Octal Binary
Binary number can easily beconverted to octal by grouping bits 3 ata time and writing the equivalent octalcharacter for each group.
Express 1 001 011 000 001 110 2 in
octal:Group the binary number by 3-bitsstarting from the right. Thus, 113016 8
-
8/12/2019 2 Number Systems Floyd
70/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
Octal Numbers
Octal is also a weighted numbersystem. The column weights are
powers of 8, which increase from rightto left.
.
3 7 0 2 8
1986 10
Column weights 83 82 81 80
512 64 8 1 .{
Express 3702 8 in decimal.
Start by writing the column weights:512 64 8 1
3(512) + 7(64) +0(8) +2(1) =
0
12345
6789101112131415
0
12345
671011121314151617
0000
00010010001101000101
0110011110001001101010111100110111101111
Decimal Octal Binary
-
8/12/2019 2 Number Systems Floyd
71/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
BCD
Binary coded decimal (BCD) is aweighted code that is commonlyused in digital systems when it isnecessary to show decimalnumbers such as in clock displays.
0
12345
6789101112131415
0000
00010010001101000101
0110011110001001101010111100110111101111
Decimal Binary BCD
000100010001000100010001
0000
00010010001101000101
0110011110001001000000010010001101000101
The table illustrates thedifference between straight binary andBCD. BCD represents each decimal
digit with a 4-bit code. Notice that thecodes 1010 through 1111 are not used inBCD.
-
8/12/2019 2 Number Systems Floyd
72/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
BCD
You can think of BCD in terms of column weights ingroups of four bits. For an 8-bit BCD number, the columnweights are: 80 40 20 10 8 4 2 1.
What are the column weights for the BCD number1000 0011 0101 1001 ?
8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 1
Note that you could add the column weights where there isa 1 to obtain the decimal number. For this case:
8000 + 200 +100 + 40 + 10 + 8 +1 = 835910
-
8/12/2019 2 Number Systems Floyd
73/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
BCDA lab experiment in which BCDis converted to decimal is shown.
-
8/12/2019 2 Number Systems Floyd
74/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
Gray code
Gray code is an unweighted codethat has a single bit change betweenone code word and the next in asequence. Gray code is used toavoid problems in systems where anerror can occur if more than one bitchanges at a time.
0
12345
6789101112131415
0000
00010010001101000101
0110011110001001101010111100110111101111
Decimal Binary Gray code
0000
00010011001001100111
0101010011001101111111101010101110011000
-
8/12/2019 2 Number Systems Floyd
75/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
Gray codeA shaft encoder is a typical application. Three IRemitter/detectors are used to encode the position of the shaft.The encoder on the left uses binary and can have three bitschange together, creating a potential error. The encoder on theright uses gray code and only 1-bit changes, eliminating
potential errors.
Binary sequence Gray code sequence
-
8/12/2019 2 Number Systems Floyd
76/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed
ASCII
ASCII is a code for alphanumeric characters and controlcharacters. In its original form, ASCII encoded 128characters and symbols using 7-bits. The first 32 charactersare control characters, that are based on obsolete teletyperequirements, so these characters are generally assigned toother functions in modern usage.
In 1981, IBM introduced extended ASCII, which is an 8-
bit code and increased the character set to 256. Otherextended sets (such as Unicode) have been introduced tohandle characters in languages other than English.
-
8/12/2019 2 Number Systems Floyd
77/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10th
ed
Parity Method
The parity method is a method of error detection forsimple transmission errors involving one bit (or an oddnumber of bits). A parity bit is an extra bit attached toa group of bits to force the number of 1s to be either
even (even parity) or odd (odd parity).The ASCII character for a is 1100001 and for A is1000001. What is the correct bit to append to make both ofthese have odd parity?
The ASCII a has an odd number of bits that are equal to 1;therefore the parity bit is 0. The ASCII A has an evennumber of bits that are equal to 1; therefore the parity bit is 1.
-
8/12/2019 2 Number Systems Floyd
78/91
2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10th
ed
Cyclic Redundancy Check
The cyclic redundancy check (CRC) is an error detection methodthat can detect multiple errors in larger blocks of data. At thesending end, a checksum is appended to a block of data. At thereceiving end, the check sum is generated and compared to the sentchecksum. If the check sums are the same, no error is detected.
Selected Key Terms
-
8/12/2019 2 Number Systems Floyd
79/91
2009 Pearson Education
Selected Key Terms
Byte
Floating-pointnumber
Hexadecimal
Octal
BCD
A group of eight bits
A number representation based on scientificnotation in which the number consists of anexponent and a mantissa.
A number system with a base of 16.
A number system with a base of 8.
Binary coded decimal; a digital code in which eachof the decimal digits, 0 through 9, is represented bya group of four bits.
Selected Key Terms
-
8/12/2019 2 Number Systems Floyd
80/91
2009 Pearson Education
Selected Key Terms
Alphanumeric
ASCII
Parity
Cyclicredundancy
check (CRC)
Consisting of numerals, letters, and othercharacters
American Standard Code for InformationInterchange; the most widely used alphanumericcode.
In relation to binary codes, the condition ofevenness or oddness in the number of 1s in a codegroup.
A type of error detection code.
-
8/12/2019 2 Number Systems Floyd
81/91
2009 Pearson Education
1. For the binary number 1000, the weight of the columnwith the 1 is
a. 4
b. 6
c. 8
d. 10
2009 Pearson Education
-
8/12/2019 2 Number Systems Floyd
82/91
2009 Pearson Education
2. The 2s complement of 1000 is
a. 0111
b. 1000c. 1001
d. 1010
2009 Pearson Education
-
8/12/2019 2 Number Systems Floyd
83/91
2009 Pearson Education
3. The fractional binary number 0.11 has a decimal value of
a.
b. c.
d. none of the above
2009 Pearson Education
-
8/12/2019 2 Number Systems Floyd
84/91
2009 Pearson Education
4. The hexadecimal number 2C has a decimal equivalentvalue of
a. 14
b. 44
c. 64
d. none of the above
2009 Pearson Education
-
8/12/2019 2 Number Systems Floyd
85/91
2009 Pearson Education
5. Assume that a floating point number is represented in binary. If the sign bit is 1, the
a. number is negative
b. number is positive
c. exponent is negative
d. exponent is positive
2009 Pearson Education
-
8/12/2019 2 Number Systems Floyd
86/91
2009 Pearson Education
6. When two positive signed numbers are added, the resultmay be larger that the size of the original numbers, creatingoverflow. This condition is indicated by
a. a change in the sign bit
b. a carry out of the sign position
c. a zero result
d. smoke
2009 Pearson Education
-
8/12/2019 2 Number Systems Floyd
87/91
2009 Pearson Education
7. The number 1010 in BCD is
a. equal to decimal eight
b. equal to decimal tenc. equal to decimal twelve
d. invalid
2009 Pearson Education
-
8/12/2019 2 Number Systems Floyd
88/91
2009 Pearson Education
8. An example of an unweighted code is
a. binary
b. decimalc. BCD
d. Gray code
2009 Pearson Education
-
8/12/2019 2 Number Systems Floyd
89/91
2009 Pearson Education
9. An example of an alphanumeric code is
a. hexadecimal
b. ASCIIc. BCD
d. CRC
2009 Pearson Education
-
8/12/2019 2 Number Systems Floyd
90/91
2009 Pearson Education
10. An example of an error detection method fortransmitted data is the
a. parity check
b. CRC
c. both of the above
d. none of the above
2009 Pearson Education
-
8/12/2019 2 Number Systems Floyd
91/91
Answers:
1. c
2. b3. c
4. b
5. a
6. a
7. d8. d
9. b
10. c