Download presentation
Presentation is loading. Please wait.
Published bySibyl Madlyn Hamilton Modified over 9 years ago
1
NUMBER SYSTEMS AND CODES
2
CS 3402--Digital LogicNumber Systems and Codes2 Outline Number systems –Number notations –Arithmetic –Base conversions –Signed number representation Codes –Decimal codes –Gray code –Error detection code –ASCII code
3
CS 3402--Digital LogicNumber Systems and Codes3 Number Systems The decimal (real), binary, octal, hexadecimal number systems are used to represent information in digital systems. Any number system consists of a set of digits and a set of operators (+, , , ).
4
CS 3402--Digital LogicNumber Systems and Codes4 Radix or Base Decimal (base 10) 0 1 2 3 4 5 6 7 8 9 Binary (base 2) 0 1 Octal (base 8) 0 1 2 3 4 5 6 7 Hexadecimal (base 16) 0 1 2 3 4 5 6 7 8 9 A B C D E F The radix or base of the number system denotes the number of digits used in the system.
5
CS 3402--Digital LogicNumber Systems and Codes5 DecimalBinaryOctalHexadecimal 000000000 010001011 020010022 030011033 040100044 050101055 060110066 070111077 081000108 091001119 10101012A 11101113B 12110014C 13110115D 14111016E 15111117F
6
CS 3402--Digital LogicNumber Systems and Codes6 Positional Notation It is convenient to represent a number using positional notation. A positional notation is written as a sequence of digits with a radix point separating the integer and fractional part. where r is the radix, n is the number of digits of the integer part, and m is the number digits of the fractional part.
7
CS 3402--Digital LogicNumber Systems and Codes7 Polynomial Notation A number can be explicitly represented in polynomial notation. where r p is a weighted position and p is the position of a digit.
8
CS 3402--Digital LogicNumber Systems and Codes8 Examples In binary number system In octal number system In hexadecimal number system
9
CS 3402--Digital LogicNumber Systems and Codes9 Arithmetic (101101) 2 +(11101) 2 : 1111 1 + 101101 11101 1001010 Addition: In binary number system,
10
CS 3402--Digital LogicNumber Systems and Codes10 Addition (6254) 8 +(5173) 8 :1 + 6254 5173 13447 In octal number system, (9F1B) 16 +(4A36) 16 : 1 1 + 9F1B 4A36 D951 In hexadecimal number system,
11
CS 3402--Digital LogicNumber Systems and Codes11 Subtraction (101101) 2 -(11011) 2 : 10 10 - 101101 11011 10010 In binary number system,
12
CS 3402--Digital LogicNumber Systems and Codes12 Subtraction In octal number system, In hexadecimal number system, (6254) 8 -(5173) 8 : 8 - 6254 5173 1061 (9F1B) 16 -(4A36) 16 : 16 - 9F1B 4A36 54E5
13
CS 3402--Digital LogicNumber Systems and Codes13 Multiplication (1101) 2 (1001) 2 : 1101 1001 1101 0000 1101 1110101 In binary number system,
14
CS 3402--Digital LogicNumber Systems and Codes14 Division (1110111) 2 (1001) 2 : 1101 10011110111 1001 1011 1001 1011 1001 10 In binary number system,
15
CS 3402--Digital LogicNumber Systems and Codes15 Base Conversions Convert (100111010) 2 to base 8
16
CS 3402--Digital LogicNumber Systems and Codes16 Base Conversion Convert (100111010) 2 to base 10
17
CS 3402--Digital LogicNumber Systems and Codes17 Base Conversion Convert (100111010) 2 to base 16
18
CS 3402--Digital LogicNumber Systems and Codes18 Base Conversion from base 8 Convert (372) 8 to base 2 Convert (372) 8 to base 10 Convert (372) 8 to base 16
19
CS 3402--Digital LogicNumber Systems and Codes19 Base Conversion from base 16 Convert (9F2) 16 to base 2 Convert (9F2) 16 to base 8 Convert (9F2) 16 to base 10
20
CS 3402--Digital LogicNumber Systems and Codes20 Binomial expansion (series substitution) To convert a number in base r to base p. –Represent the number in base p in binomial series. –Change the radix or base of each term to base p. –Simplify.
21
CS 3402--Digital LogicNumber Systems and Codes21 Convert Base 10 to Base r Convert (174) 10 to base 8 Therefore (174) 10 = (256) 8 81746LSB 8215 822MSB 00
22
CS 3402--Digital LogicNumber Systems and Codes22 Convert Base 10 to Base r Convert (0.275) 10 to base 8 Therefore (0.275) 10 = (0.21463 ) 8 8 0.275 2.200MSD 8 0.200 1.600 8 0.600 4.800 8 0.800 6.400 8 0.400 3.200LSD
23
CS 3402--Digital LogicNumber Systems and Codes23 Convert Base 10 to Base r Convert (0.68475) 10 to base 2 Therefore (0.68475) 10 = (0.10101 ) 2 2 0.68475 1. 3695MSD 2 0.3695 0.7390 2 1.4780 2 0.4780 0.9560 2 1.9120LSD
24
CS 3402--Digital LogicNumber Systems and Codes24 Signed Number Representation There are 3 systems to represent signed numbers in binary number system: – Signed-magnitude –1's complement –2's complement
25
CS 3402--Digital LogicNumber Systems and Codes25 Signed-magnitude system In signed-magnitude systems, the most significant bit represents the number's sign, while the remaining bits represent its absolute value as an unsigned binary magnitude. –If the sign bit is a 0, the number is positive. –If the sign bit is a 1, the number is negative.
26
CS 3402--Digital LogicNumber Systems and Codes26 Signed-magnitude system
27
CS 3402--Digital LogicNumber Systems and Codes27 1's Complement system A 1's complement system represents the positive numbers the same way as in the signed-magnitude system. The only difference is negative number representations. Let be N any positive integer number and be a negative 1's complement integer of N. If the number length is n bits, then
28
CS 3402--Digital LogicNumber Systems and Codes28 Example of 1's Complement For example in a 4-bit system, 0101 represents +5 and 1010 represents 5
29
CS 3402--Digital LogicNumber Systems and Codes29 1's Complement system
30
CS 3402--Digital LogicNumber Systems and Codes30 2's Complement system A 2's complement system is similar to 1's complement system, except that there is only one representation for zero. Let be N any positive integer number and be a negative 2's complement integer of N. If the number length is n bits, then
31
CS 3402--Digital LogicNumber Systems and Codes31 Example of 2's Complement For example in a 4-bit system, 0101 represents +5 and 1011 represents 5
32
CS 3402--Digital LogicNumber Systems and Codes32 2's Complement system
33
CS 3402--Digital LogicNumber Systems and Codes33 Addition and Subtraction in Signed and Magnitude
34
CS 3402--Digital LogicNumber Systems and Codes34 Addition and Subtraction in 1’s Complement
35
CS 3402--Digital LogicNumber Systems and Codes35 Addition and Subtraction in 2’s Complement
36
CS 3402--Digital LogicNumber Systems and Codes36 Overflow Conditions Carry-in carry-out 0111 1000 5 0101 -5 1011 +3 +0011 -4 +1100 -8 1000 7 10111 Carry-in = carry-out 0000 1110 +5 0101 -2 1110 +2 +0010 -6 +1010 7 0111 -8 11000
37
CS 3402--Digital LogicNumber Systems and Codes37 Addition and Subtraction in Hexadecimal System Addition Subtraction
38
CS 3402--Digital LogicNumber Systems and Codes38 Codes Decimal codes Gray code Error detection code ASCII code
39
CS 3402--Digital LogicNumber Systems and Codes39 Decimal codes Decimal DigitBCDExcess-3 2421 8421 0000000110000 1000101000001 2001001010010 3001101100011 4010001110100 5010110001011 6011010011100 7011110101101 8100010111110 9100111001111
40
CS 3402--Digital LogicNumber Systems and Codes40 Gray Code Decimal EquivalentBinary CodeGray Code 00000 10001 200100011 3 0010 401000110 501010111 601100101 701110100 810001100 910011101 1010101111 1110111110 1211001010 1311011011 1411101001 1511111000
41
CS 3402--Digital LogicNumber Systems and Codes41 Error detection code Parity Bit (odd)Message 10000 00001 00010 10011 00100 10101 10110 00111 01000 11001 11010 01011 11100 01101 01110 11111
42
CS 3402--Digital LogicNumber Systems and Codes42 Error detection code Parity Bit (even)Message 00000 10001 10010 00011 10100 00101 00110 10111 11000 01001 01010 11011 01100 11101 11110 01111
43
CS 3402--Digital LogicNumber Systems and Codes43 ASCII Code ASCII: American Standard Code for Information Interchange. Used to represent characters and textual information Each character is represented with 1 byte –upper and lower case letters: a..z and A..Z –decimal digits -- 0,1,…,9 – punctuation characters -- ;,. : –special characters --$ & @ / { –control characters -- carriage return (CR), line feed (LF), beep
44
CS 3402--Digital LogicNumber Systems and Codes44 Assignment 1 Page 74 –1.1: Only A+B and A B (a), (c), (f), and (g) –1.2: Only A+B and A B (a), (c) –1.3: Only A+B and A B (a), (c) –1.4: (a), (c), (e) –1.5: (a), (c), (e) –1.6: (a), (e) –1.7: (a), (b) –1.8: (a), (b) –1.10: (a), (c) –1.11: (a), (c) –1.12: (a), (c) –1.13: (a), (b)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.