1. number systems chapt. 2 location in course textbook
TRANSCRIPT
![Page 1: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/1.jpg)
1. Number Systems
Chapt. 2
Location in course textbook
![Page 2: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/2.jpg)
Quantities/Counting (1 of 3)
Decimal Binary Octal
Hexa-decimal
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
p. 33
![Page 3: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/3.jpg)
Quantities/Counting (2 of 3)
Decimal Binary Octal
Hexa-decimal
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
![Page 4: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/4.jpg)
Quantities/Counting (3 of 3)
Decimal Binary Octal
Hexa-decimal
16 10000 20 10
17 10001 21 11
18 10010 22 12
19 10011 23 13
20 10100 24 14
21 10101 25 15
22 10110 26 16
23 10111 27 17 Etc.
![Page 5: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/5.jpg)
Conversion Among Bases
The possibilities:
Hexadecimal
Decimal Octal
Binary
pp. 40-46
![Page 6: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/6.jpg)
Quick Example
2510 = 110012 = 318 = 1916
Base
![Page 7: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/7.jpg)
Decimal to Decimal (just for fun)
Hexadecimal
Decimal Octal
Binary
Next slide…
![Page 8: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/8.jpg)
12510 => 5 x 100 = 52 x 101 = 201 x 102 = 100
125
Base
Weight
![Page 9: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/9.jpg)
Binary to Decimal
Hexadecimal
Decimal Octal
Binary
![Page 10: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/10.jpg)
Binary to Decimal
Technique Multiply each bit by 2n, where n is the “weight”
of the bit The weight is the position of the bit, starting
from 0 on the right Add the results
![Page 11: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/11.jpg)
Example
1010112 => 1 x 20 = 11 x 21 = 20 x 22 = 01 x 23 = 80 x 24 = 01 x 25 = 32
4310
Bit “0”
![Page 12: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/12.jpg)
Octal to Decimal
Hexadecimal
Decimal Octal
Binary
![Page 13: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/13.jpg)
Octal to Decimal
Technique Multiply each bit by 8n, where n is the “weight”
of the bit The weight is the position of the bit, starting
from 0 on the right Add the results
![Page 14: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/14.jpg)
Example
7248 => 4 x 80 = 42 x 81 = 167 x 82 = 448
46810
![Page 15: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/15.jpg)
Hexadecimal to Decimal
Hexadecimal
Decimal Octal
Binary
![Page 16: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/16.jpg)
Hexadecimal to Decimal
Technique Multiply each bit by 16n, where n is the
“weight” of the bit The weight is the position of the bit, starting
from 0 on the right Add the results
![Page 17: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/17.jpg)
Example
ABC16 => C x 160 = 12 x 1 = 12 B x 161 = 11 x 16 = 176 A x 162 = 10 x 256 = 2560
274810
![Page 18: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/18.jpg)
Decimal to Binary
Hexadecimal
Decimal Octal
Binary
![Page 19: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/19.jpg)
Decimal to Binary
Technique Divide by two, keep track of the remainder First remainder is bit 0 (LSB, least-significant
bit) Second remainder is bit 1 Etc.
![Page 20: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/20.jpg)
Example12510 = ?2
2 125 62 12 31 02 15 12 7 12 3 12 1 12 0 1
12510 = 11111012
![Page 21: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/21.jpg)
Octal to Binary
Hexadecimal
Decimal Octal
Binary
![Page 22: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/22.jpg)
Octal to Binary
Technique Convert each octal digit to a 3-bit equivalent
binary representation
![Page 23: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/23.jpg)
Example7058 = ?2
7 0 5
111 000 101
7058 = 1110001012
![Page 24: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/24.jpg)
Hexadecimal to Binary
Hexadecimal
Decimal Octal
Binary
![Page 25: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/25.jpg)
Hexadecimal to Binary
Technique Convert each hexadecimal digit to a 4-bit
equivalent binary representation
![Page 26: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/26.jpg)
Example10AF16 = ?2
1 0 A F
0001 0000 1010 1111
10AF16 = 00010000101011112
![Page 27: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/27.jpg)
Decimal to Octal
Hexadecimal
Decimal Octal
Binary
![Page 28: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/28.jpg)
Decimal to Octal
Technique Divide by 8 Keep track of the remainder
![Page 29: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/29.jpg)
Example123410 = ?8
8 1234 154 28 19 28 2 38 0 2
123410 = 23228
![Page 30: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/30.jpg)
Decimal to Hexadecimal
Hexadecimal
Decimal Octal
Binary
![Page 31: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/31.jpg)
Decimal to Hexadecimal
Technique Divide by 16 Keep track of the remainder
![Page 32: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/32.jpg)
Example123410 = ?16
123410 = 4D216
16 1234 77 216 4 13 = D16 0 4
![Page 33: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/33.jpg)
Binary to Octal
Hexadecimal
Decimal Octal
Binary
![Page 34: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/34.jpg)
Binary to Octal
Technique Group bits in threes, starting on right Convert to octal digits
![Page 35: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/35.jpg)
Example10110101112 = ?8
1 011 010 111
1 3 2 7
10110101112 = 13278
![Page 36: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/36.jpg)
Binary to Hexadecimal
Hexadecimal
Decimal Octal
Binary
![Page 37: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/37.jpg)
Binary to Hexadecimal
Technique Group bits in fours, starting on right Convert to hexadecimal digits
![Page 38: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/38.jpg)
Example10101110112 = ?16
10 1011 1011
2 B B
10101110112 = 2BB16
![Page 39: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/39.jpg)
Octal to Hexadecimal
Hexadecimal
Decimal Octal
Binary
![Page 40: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/40.jpg)
Octal to Hexadecimal
Technique Use binary as an intermediary
![Page 41: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/41.jpg)
Example10768 = ?16
1 0 7 6
001 000 111 110
2 3 E
10768 = 23E16
![Page 42: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/42.jpg)
Hexadecimal to Octal
Hexadecimal
Decimal Octal
Binary
![Page 43: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/43.jpg)
Hexadecimal to Octal
Technique Use binary as an intermediary
![Page 44: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/44.jpg)
Example1F0C16 = ?8
1 F 0 C
0001 1111 0000 1100
1 7 4 1 4
1F0C16 = 174148
![Page 45: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/45.jpg)
Exercise – Convert ...
Don’t use a calculator!
Decimal Binary Octal
Hexa-decimal
33
1110101
703
1AF
Skip answer Answer
![Page 46: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/46.jpg)
Exercise – Convert …
Decimal Binary Octal
Hexa-decimal
33 100001 41 21
117 1110101 165 75
451 111000011 703 1C3
431 110101111 657 1AF
Answer
![Page 47: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/47.jpg)
Common Powers (1 of 2)
Base 10Power Preface Symbol
10-12 pico p
10-9 nano n
10-6 micro
10-3 milli m
103 kilo k
106 mega M
109 giga G
1012 tera T
Value
.000000000001
.000000001
.000001
.001
1000
1000000
1000000000
1000000000000
![Page 48: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/48.jpg)
Common Powers (2 of 2)
Base 2Power Preface Symbol
210 kilo k
220 mega M
230 Giga G
Value
1024
1048576
1073741824
• What is the value of “k”, “M”, and “G”?• In computing, particularly w.r.t. memory, the base-2 interpretation generally applies
![Page 49: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/49.jpg)
Example
/ 230 =
In the lab…1. Double click on My Computer2. Right click on C:3. Click on Properties
![Page 50: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/50.jpg)
Exercise – Free Space
Determine the “free space” on all drives on a machine in the lab
Drive
Free space
Bytes GB
A:
C:
D:
E:
etc.
![Page 51: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/51.jpg)
Review – multiplying powers
For common bases, add powers
26 210 = 216 = 65,536
or…
26 210 = 64 210 = 64k
ab ac = ab+c
![Page 52: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/52.jpg)
Binary Addition (1 of 2)
Two 1-bit values
pp. 36-38
A B A + B
0 0 0
0 1 1
1 0 1
1 1 10
“two”
![Page 53: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/53.jpg)
Binary Addition (2 of 2)
Two n-bit values Add individual bits Propagate carries E.g.,
10101 21+ 11001 + 25 101110 46
11
![Page 54: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/54.jpg)
Multiplication (1 of 3)
Decimal (just for fun)
pp. 39
35x 105 175 000 35 3675
![Page 55: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/55.jpg)
Multiplication (2 of 3)
Binary, two 1-bit values
A B A B
0 0 0
0 1 0
1 0 0
1 1 1
![Page 56: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/56.jpg)
Multiplication (3 of 3)
Binary, two n-bit values As with decimal values E.g.,
1110 x 1011 1110 1110 0000 111010011010
![Page 57: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/57.jpg)
Fractions
Decimal to decimal (just for fun)
pp. 46-50
3.14 => 4 x 10-2 = 0.041 x 10-1 = 0.1
3 x 100 = 3 3.14
![Page 58: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/58.jpg)
Fractions
Binary to decimal
pp. 46-50
10.1011 => 1 x 2-4 = 0.06251 x 2-3 = 0.1250 x 2-2 = 0.01 x 2-1 = 0.50 x 20 = 0.01 x 21 = 2.0 2.6875
![Page 59: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/59.jpg)
Fractions
Decimal to binary
p. 50
3.14579
.14579x 20.29158x 20.58316x 21.16632x 20.33264x 20.66528x 21.33056
etc.11.001001...
![Page 60: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/60.jpg)
Exercise – Convert ...
Don’t use a calculator!
Decimal Binary Octal
Hexa-decimal
29.8
101.1101
3.07
C.82
Skip answer Answer
![Page 61: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/61.jpg)
Exercise – Convert …
Decimal Binary Octal
Hexa-decimal
29.8 11101.110011… 35.63… 1D.CC…
5.8125 101.1101 5.64 5.D
3.109375 11.000111 3.07 3.1C
12.5078125 1100.10000010 14.404 C.82
Answer
![Page 62: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/62.jpg)
• Representing one decimal number at a time
• How can we represent the ten decimal numbers (0-9) in binary code?
NumeralNumeral00112233445566778899
BCD RepresentationBCD Representation00000000000100010010001000110011010001000101010101100110011101111000100010011001
We can represent any integer by a string of binary digits. For example, 749 can be represented in binary as: 011101001001
Binary Coded Decimal (BCD)
![Page 63: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/63.jpg)
63
How Many Bits Are Necessary to Represent Something? 1 bit can represent two (21) symbols
either a 0 or a 1 2 bits can represent four (22) symbols
00 or 01 or 10 or 11 3 bits can represent eight (23) symbols
000 or 001 or 011 or 111 or 100 or 110 or 101 or 010 4 bits can represent sixteen (24) symbols 5 bits can represent 32 (25) symbols 6 bits can represent 64 (26) symbols 7 bits can represent 128 (27) symbols 8 bits (a byte) can represent 256 (28) symbols n bits can represent (2n) symbols! So…how many bits are necessary for all of us in class to have a unique
binary ID? Are two bits enough? Three? Four? Five? Six? Seven?
![Page 64: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/64.jpg)
64
Binary CodesA binary code is a group of n bits that assume up to 2n distinct combinations of 1’s and 0’s with each combination representing one element of the set that is being coded.
![Page 65: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/65.jpg)
65
Binary Digital Codes
• Gray Code – Gray Code
• BCD 2421 – BCD 2421 code
• BCD XS 3 – BCD Excess 3 code
• BCD 8421 – BCD 8421 code
• EBCDIC – Extended BCD Interchange Code
![Page 66: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/66.jpg)
66
BCD – Binary Coded Decimal
6 3 4 9
0110 0011 0100 1001
BCD is a convention for mapping binary numbers to decimal numbers.
When the decimal numbers are represented in BCD, each decimal digit is represented by the equivalent BCD code.
Example :BCD Representation of Decimal 6349
![Page 67: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/67.jpg)
67
BCD – Binary Coded DecimalDecimal BCD
Number Number
0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001
![Page 68: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/68.jpg)
68
The excess-3 code is obtained by adding 3 (0011) to the corresponding BCD equivalent binary number.
Excess-3 have a self-complementing property
EXCESS 3 CODE
![Page 69: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/69.jpg)
69
EXCESS 3 CODEDecimal BCD Excess-3Number Number Number
0 0000 0011 1 0001 0100 2 0010 0101 3 0011 0110 4 0100 0111 5 0101 1000 6 0110 1001 7 0111 1010 8 1000 1011 9 1001 1100
![Page 70: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/70.jpg)
70
BCD-to-Excess-3 Table
![Page 71: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/71.jpg)
71
BCD – Binary Coded Decimal
Decimal BCDNumber Number
10 0001 0000 121 0001 0010 0001 234 0010 0011 0100 1003 0001 0000 0000 0011
![Page 72: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/72.jpg)
72
2421 and excess-3 have a self-complementing property 9’s complement is obtained by 1’s to 0’s and 0’s to
1’s. Useful property when doing arithmetic operations
with signed complement representation. This code is widely used in instruments and
electronic calculators.
BCD 2421 CODE
![Page 73: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/73.jpg)
73
Unweighted and is not an arithmetic code Only one bit changes from one code to the next in the
sequence Gray code can be any amounts of bits. The gray code originated when digital logic circuits
were built from vacuum tubes and electromechanical relays
Counters generated tremendous power demands and noise spikes when many bits changed at once
Using gray code counters, any increment or decrement changed only one bit
GRAY CODE
![Page 74: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/74.jpg)
DECIMAL BINARY GRAY CODE
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
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
GRAY CODE
![Page 75: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/75.jpg)
75
VARIOUS DECIMAL CODES
![Page 76: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/76.jpg)
Sign Magnitude
An extra bit in the most significant position is designated as the sign bit which is to the left of an unsigned integer. The unsigned integer is the magnitude.
A 0 in the sign bit means positive, and a 1 means negative
xxx xxxxx
![Page 77: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/77.jpg)
Sign Extension - complement
For positive number, a 0 is used to stuff the remaining positions.
For negative number, a 1 is used to stuff the remaining positions.
0xxxxxxx
000000000xxxxxxx
1xxxxxxx
111111111xxxxxxx
The original number isplaced into the least significant portion
The original number isplaced into the least significant portion
![Page 78: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/78.jpg)
2- Find the 9’s complement of 546700 and 12389
The 9’s complement of 546700 is 999999 - 546700= 453299
and the 9’s complement of 12389 is 99999- 12389 = 87610.
9’s complement Examples
5 4 6 7 0- 0
9 9 9 9 9 9
4 5 3 2 9 9
1 2 3 8- 9
9 9 9 9 9
8 7 6 1 0
![Page 79: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/79.jpg)
l’s complement
For binary numbers, r = 2 and r — 1 = 1, r-1’s complement is the l’s complement. The l’s complement of N is (2n - 1) - N.
Digit n
Digit n-1
Next digit
Next digit
First digit
1 1 1 1 1
Bit n-1 Bit n-2 ……. Bit 1 Bit 0
-
![Page 80: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/80.jpg)
l’s complement
Find r-1 complement for binary number N with four binary digits.
r-1 complement for binary means 2-1 complement or 1’s complement.
n = 4, we have 24 = (10000)2 and 24 - 1 = (1111)2.
The l’s complement of N is (24 - 1) - N. = (1111) - N
![Page 81: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/81.jpg)
The complement 1’s of1011001 is 0100110
0 1 1 0 0- 1
1 1 1 1 1 1
1 0 0 1 1 0
0 0 1 1 1- 1
1 1 1 1 1 1
1 1 0 0 0 0
1
1
0
The 1’s complement of0001111 is 1110000
0
1
1
l’s complement
![Page 82: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/82.jpg)
10’s complement Examples
Find the 10’s complement of 546700 and 12389
The 10’s complement of 546700 is 1000000 - 546700= 453300
and the 10’s complement of 12389 is
100000 - 12389 = 87611.
Notice that it is the same as 9’s complement + 1.
5 4 6 7 0- 0
0 0 0 0 0 0
4 5 3 3 0 0
1 2 3 8- 9
1 0 0 0 0 0
8 7 6 1 1
1
![Page 83: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/83.jpg)
For binary numbers, r = 2,
r’s complement is the 2’s complement.
The 2’s complement of N is 2n - N.
2’s complement
Digit n
Digit n-1
Next digit
Next digit
First digit
0 0 0 0 0
-1
![Page 84: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/84.jpg)
2’s complement Example
The 2’s complement of1011001 is 0100111
The 2’s complement of0001111 is 1110001
0 1 1 0 0- 1
0 0 0 0 0 0
1 0 0 1 1 1
0 0 1 1 1- 1
1 1 0 0 0 1
1
0
0
0
1
1
0 0 0 0 0 001
![Page 85: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/85.jpg)
Fast Methods for 2’s Complement
Method 1:The 2’s complement of binary number is obtained by adding 1 to the l’s complement value.Example:1’s complement of 101100 is 010011 (invert the 0’s and 1’s)2’s complement of 101100 is 010011 + 1 = 010100
![Page 86: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/86.jpg)
Fast Methods for 2’s Complement
Method 2:The 2’s complement can be formed by leaving all least significant 0’s and the first 1 unchanged, and then replacing l’s by 0’s and 0’s by l’s in all other higher significant bits.
Example:The 2’s complement of 1101100 is
0010100 Leave the two low-order 0’s and the first 1 unchanged, and then replacing 1’s by 0’s and 0’s by 1’s in the four most significant bits.
![Page 87: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/87.jpg)
Examples Finding the 2’s complement of (01100101)2
Method 1 – Simply complement each bit and then add 1 to the result. (01100101)2
[N] = 2’s complement = 1’s complement (10011010)2 +1
=(10011011)2
Method 2 – Starting with the least significant bit, copy all the bits up to and including the first 1 bit and then complement the remaining bits.
N = 0 1 1 0 0 1 0 1[N] = 1 0 0 1 1 0 1 1
![Page 88: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/88.jpg)
Binary Coded Decimal
Introduction:
Although binary data is the most efficient storage scheme; every bit pattern represents a unique, valid value. However, some applications may not be desirable to work with binary data.
For instance, the internal components of digital clocks keep track of the time in binary. The binary value must be converted to decimal before it can be displayed.
![Page 89: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/89.jpg)
Binary Coded Decimal
Because a digital clock is preferable to store the value as a series of decimal digits, where each digit is separately represented as its binary equivalent, the most common format used to represent decimal data is called binary coded decimal, or BCD.
![Page 90: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/90.jpg)
1) BCD Numeric Format
Every four bits represent one decimal digit.
Use decimal values
from 0 to 9
![Page 91: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/91.jpg)
4-bit values above 9 are not used in BCD.
1) BCD Numeric Format
The unused 4-bit values are:
BCD Decimal
1010 10
1011 11
1100 12
1101 13
1110 14
1111 15
![Page 92: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/92.jpg)
1) BCD Numeric Format
Multi-digit decimal numbers are stored as multiple groups of 4 bits per digit.
![Page 93: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/93.jpg)
2) Algorithms for Addition
1100 is not used in BCD.
![Page 94: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/94.jpg)
2) Algorithms for Addition
Two errors will occurs in a standard binary adder.
1) The result is not a valid BCD digit.
2) A valid BCD digit, but not the correct result.
Solution: You need to add 6 to the result generated by a binary adder.
![Page 95: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/95.jpg)
2) Algorithms for Addition
A simple example of addition in BCD.
0101
+ 1001
1110
+ 0110
1 0100
5
+ 9
Incorrect BCD digit
Add 6
Correct answer
1 4
![Page 96: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/96.jpg)
Binary Coded Decimal
ex1: dec-to-BCD
(a) 35
(b) 98
(c) 170
(d) 2469
ex2: BCD-to-dec
(a) 10000110
(b) 001101010001
(c) 1001010001110000
Decimal Digit
0 1 2 3 4 5 6 7 8 9
BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
Let’s crack these…
Note: 1010, 1011, 1100, 1101, 1110, and 1111 are INVALID CODE!
![Page 97: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/97.jpg)
BCD Addition BCD is a numerical code and can be used in
arithmetic operations. Here is how to add two BCD numbers: Add the two BCD numbers, using the rules for
basic binary addition. If a 4-bit sum is equal to or less than 9, it is a
valid BCD number. If a 4-bit sum > 9, or if a carry out of the 4-bit
group is generated it is an invalid result. Add 6 (0110) to a 4-bit sum in order to skip the six the invalid states and return the code to 8421. If a carry results when 6 is added, simply add the carry to the next 4-bit group.
![Page 98: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/98.jpg)
BCD Addition Try these:
ex: Add the following numbers
(a) 0011+0100(b) 00100011 + 00010101(c) 10000110 + 00010011(d) 010001010000 + 010000010111(e) 1001 + 0100(f) 1001 + 1001(g) 00010110 + 00010101(h) 01100111 + 01010011
![Page 99: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/99.jpg)
The Gray Code
The Gray code is unweighted and is not an arithmetic code. There are no specific weights assigned to the
bit positions. Important: the Gray code exhibits only a
single bit change from one code word to the next in sequence. This property is important in many
applications, such as shaft position encoders.
![Page 100: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/100.jpg)
The Gray CodeDecimal Binary Gray Code
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
Decimal Binary Gray Code
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
![Page 101: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/101.jpg)
The Gray Code Binary-to-Gray code conversion
The MSB in the Gray code is the same as corresponding MSB in the binary number.
Going from left to right, add each adjacent pair of binary code bits to get the next Gray code bit. Discard carries.
ex: convert 101102 to Gray code
1 + 0 + 1 + 1 + 0 binary
1 1 1 0 1 Gray
![Page 102: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/102.jpg)
The Gray Code
Gray-to-Binary Conversion The MSB in the binary code is the same as
the corresponding bit in the Gray code. Add each binary code bit generated to the
Gray code bit in the next adjacent position. Discard carries.
ex: convert the Gray code word 11011 to binary
1 1 0 1 1 Gray
+ + + +1 0 0 1 0 Binary
![Page 103: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/103.jpg)
Alphanumeric Codes
Represent numbers and alphabetic characters. Also represent other characters such as
symbols and various instructions necessary for conveying information.
The ASCII is the most common alphanumeric code. ASCII = American Standard Code for
Information Interchange
![Page 104: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/104.jpg)
ASCII
ASCII has 128 characters and symbols represented by a 7-bit binary code.
(the first 32) – control characters graphics symbols (can be printed or displayed)
![Page 105: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/105.jpg)
Introduction(Error Checking Code) All transmitted signals will contain some rate of errors (>0%) because
noise is always present If a communications line experiences too much noise, the signal will be
lost or corrupted Once an error is detected, a system may perform some
action, or may do nothing but simply let the data in error be discarded
Popular error detection methods: Simple Parity (add a 1 or 0 to the end of each seven bits) Longitudinal Parity or Longitudinal Redundancy Check (LRC) Cyclic Redundancy Checksum (CRC), or called Polynomial
checking
![Page 106: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/106.jpg)
Simple Parity Occasionally known as vertical redundancy check Add an additional bit to a string of bits:
Even parity The 0 or 1 added to the string produces an even number of 1s
(including the parity bit) Odd parity
The 0 or 1 added … an odd number of 1s (including the parity bit)
0 1 0 1 0 1 01 Even parity
0 Odd parity
![Page 107: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/107.jpg)
The key to the Hamming Code is the use of extra parity bits to allow the identification of a single error. Create the code word as follows:
Mark all bit positions that are powers of two as parity bits. (positions 1, 2, 4, 8, 16, 32, 64, etc.)
All other bit positions are for the data to be encoded. (positions 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, etc.)
Each parity bit calculates the parity for some of the bits in the code word. The position of the parity bit determines the sequence of bits that it alternately checks and skips.
Position 1: check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, etc. (1,3,5,7,9,11,13,15,...)Position 2: check 2 bits, skip 2 bits, check 2 bits, skip 2 bits, etc. (2,3,6,7,10,11,14,15,...)
Position 4: check 4 bits, skip 4 bits, check 4 bits, skip 4 bits, etc. (4,5,6,7,12,13,14,15,20,21,22,23,...)
Position 8: check 8 bits, skip 8 bits, check 8 bits, skip 8 bits, etc. (8-15,24-31,40-47,...)Position 16: check 16 bits, skip 16 bits, check 16 bits, skip 16 bits, etc. (16-31,48-63,80-95,...)
Position 32: check 32 bits, skip 32 bits, check 32 bits, skip 32 bits, etc. (32-63,96-127,160-191,...)
etc. Set a parity bit to 1 if the total number of ones in the positions it checks is odd. Set a parity bit
to 0 if the total number of ones in the positions it checks is even.
Calculating the Hamming Code
![Page 108: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/108.jpg)
Example Here is an example: A byte of data: 10011010
Create the data word, leaving spaces for the parity bits: _ _ 1 _ 0 0 1 _ 1 0 1 0Calculate the parity for each parity bit (a ? represents the bit position being set):
Position 1 checks bits 1,3,5,7,9,11: ? _ 1 _ 0 0 1 _ 1 0 1 0. Even parity so set position 1 to a 0: 0 _ 1 _ 0 0 1 _ 1 0 1 0
Position 2 checks bits 2,3,6,7,10,11:0 ? 1 _ 0 0 1 _ 1 0 1 0. Odd parity so set position 2 to a 1: 0 1 1 _ 0 0 1 _ 1 0 1 0
Position 4 checks bits 4,5,6,7,12:0 1 1 ? 0 0 1 _ 1 0 1 0. Odd parity so set position 4 to a 1: 0 1 1 1 0 0 1 _ 1 0 1 0
Position 8 checks bits 8,9,10,11,12:0 1 1 1 0 0 1 ? 1 0 1 0. Even parity so set position 8 to a 0: 0 1 1 1 0 0 1 0 1 0 1 0
Code word: 011100101010.
![Page 109: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/109.jpg)
Finding and fixing a bad bit The above example created a code word of 011100101010. Suppose the word that was received was 011100101110 instead. Then the receiver could calculate which bit was wrong and correct it. The method is to verify each check bit. Write down all the incorrect parity bits. Doing so, you will discover that parity bits 2 and 8 are incorrect. It is not an accident that 2 + 8 = 10, and that bit position 10 is the location of the bad bit. In general, check each parity bit, and add the positions that are wrong, this will give you the location of the bad bit. Try one yourself Test if these code words are correct, assuming they were created using an even parity Hamming Code . If one is incorrect, indicate what the correct code word should have been. Also, indicate what the original
data was. 010101100011 111110001100 000010001010
![Page 110: 1. Number Systems Chapt. 2 Location in course textbook](https://reader035.vdocuments.site/reader035/viewer/2022062517/56649f1b5503460f94c319d9/html5/thumbnails/110.jpg)
A byte of data: 10011010Create the data word, leaving spaces for the parity bits: _ _ 1 _ 0 0 1 _ 1 0 1 0
Calculate the parity for each parity bit (a ? represents the bit position being set):
Position 1 checks bits 1,3,5,7,9,11:
? _ 1 _ 0 0 1 _ 1 0 1 0. Even parity so set position 1 to a 0: 0 _ 1 _ 0 0 1 _ 1 0 1 0
Position 2 checks bits 2,3,6,7,10,11:
0 ? 1 _ 0 0 1 _ 1 0 1 0. Odd parity so set position 2 to a 1: 0 1 1 _ 0 0 1 _ 1 0 1 0
Position 4 checks bits 4,5,6,7,12:
0 1 1 ? 0 0 1 _ 1 0 1 0. Odd parity so set position 4 to a 1: 0 1 1 1 0 0 1 _ 1 0 1 0
Position 8 checks bits 8,9,10,11,12:
0 1 1 1 0 0 1 ? 1 0 1 0. Even parity so set position 8 to a 0: 0 1 1 1 0 0 1 0 1 0 1 0
Code word: 011100101010.