NUMBER SYSTEMS AND CODES
CS 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
CS 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 (+, , , ).
CS Digital LogicNumber Systems and Codes4 Radix or Base Decimal (base 10) Binary (base 2) 0 1 Octal (base 8) Hexadecimal (base 16) A B C D E F The radix or base of the number system denotes the number of digits used in the system.
CS Digital LogicNumber Systems and Codes5 DecimalBinaryOctalHexadecimal A B C D E F
CS 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.
CS 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.
CS Digital LogicNumber Systems and Codes8 Examples In binary number system In octal number system In hexadecimal number system
CS Digital LogicNumber Systems and Codes9 Arithmetic (101101) 2 +(11101) 2 : Addition: In binary number system,
CS Digital LogicNumber Systems and Codes10 Addition (6254) 8 +(5173) 8 : In octal number system, (9F1B) 16 +(4A36) 16 : F1B 4A36 D951 In hexadecimal number system,
CS Digital LogicNumber Systems and Codes11 Subtraction (101101) 2 -(11011) 2 : In binary number system,
CS Digital LogicNumber Systems and Codes12 Subtraction In octal number system, In hexadecimal number system, (6254) 8 -(5173) 8 : (9F1B) 16 -(4A36) 16 : F1B 4A36 54E5
CS Digital LogicNumber Systems and Codes13 Multiplication (1101) 2 (1001) 2 : In binary number system,
CS Digital LogicNumber Systems and Codes14 Division ( ) 2 (1001) 2 : In binary number system,
CS Digital LogicNumber Systems and Codes15 Base Conversions Convert ( ) 2 to base 8
CS Digital LogicNumber Systems and Codes16 Base Conversion Convert ( ) 2 to base 10
CS Digital LogicNumber Systems and Codes17 Base Conversion Convert ( ) 2 to base 16
CS 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
CS 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
CS 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.
CS Digital LogicNumber Systems and Codes21 Convert Base 10 to Base r Convert (174) 10 to base 8 Therefore (174) 10 = (256) LSB MSB 00
CS Digital LogicNumber Systems and Codes22 Convert Base 10 to Base r Convert (0.275) 10 to base 8 Therefore (0.275) 10 = ( ) 8 8 2.200MSD 8 3.200LSD
CS Digital LogicNumber Systems and Codes23 Convert Base 10 to Base r Convert ( ) 10 to base 2 Therefore ( ) 10 = ( ) 2 2 MSD 2 LSD
CS 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
CS 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.
CS Digital LogicNumber Systems and Codes26 Signed-magnitude system
CS 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
CS Digital LogicNumber Systems and Codes28 Example of 1's Complement For example in a 4-bit system, 0101 represents +5 and 1010 represents 5
CS Digital LogicNumber Systems and Codes29 1's Complement system
CS 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
CS Digital LogicNumber Systems and Codes31 Example of 2's Complement For example in a 4-bit system, 0101 represents +5 and 1011 represents 5
CS Digital LogicNumber Systems and Codes32 2's Complement system
CS Digital LogicNumber Systems and Codes33 Addition and Subtraction in Signed and Magnitude
CS Digital LogicNumber Systems and Codes34 Addition and Subtraction in 1’s Complement
CS Digital LogicNumber Systems and Codes35 Addition and Subtraction in 2’s Complement
CS Digital LogicNumber Systems and Codes36 Overflow Conditions Carry-in carry-out Carry-in = carry-out
CS Digital LogicNumber Systems and Codes37 Addition and Subtraction in Hexadecimal System Addition Subtraction
CS Digital LogicNumber Systems and Codes38 Codes Decimal codes Gray code Error detection code ASCII code
CS Digital LogicNumber Systems and Codes39 Decimal codes Decimal DigitBCDExcess
CS Digital LogicNumber Systems and Codes40 Gray Code Decimal EquivalentBinary CodeGray Code
CS Digital LogicNumber Systems and Codes41 Error detection code Parity Bit (odd)Message
CS Digital LogicNumber Systems and Codes42 Error detection code Parity Bit (even)Message
CS 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
CS 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)