920 likes | 1.71k Views
NUMBER SYSTEMS AND CODES. Outline. Number systems Number notations Arithmetic Base conversions Signed number representation Codes Decimal codes Gray code Error detection code ASCII code. Number Systems.
E N D
Outline • Number systems • Number notations • Arithmetic • Base conversions • Signed number representation • Codes • Decimal codes • Gray code • Error detection code • ASCII code Number Systems and Codes
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 (+, , , ). Number Systems and Codes
Radix or Base Theradix or base of the number system denotes the number of digits used in the system. Number Systems and Codes
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. Number Systems and Codes
Polynomial Notation A number can be explicitly represented in polynomial notation. where rpis a weighted position and p is the position of a digit. Number Systems and Codes
Examples In binary number system In octal number system In hexadecimal number system Number Systems and Codes
Arithmetic Addition: In binary number system, Number Systems and Codes
Addition In octal number system, In hexadecimal number system, Number Systems and Codes
Subtraction In binary number system, Number Systems and Codes
Subtraction In octal number system, In hexadecimal number system, Number Systems and Codes
Multiplication In binary number system, Number Systems and Codes
Division In binary number system, Number Systems and Codes
Base Conversions Convert (100111010)2 to base 8 Number Systems and Codes
Base Conversion Convert (100111010)2 to base 10 Number Systems and Codes
Base Conversion Convert (100111010)2 to base 16 Number Systems and Codes
Base Conversion from base 8 • Convert (372)8 to base 2 • Convert (372)8 to base 10 • Convert (372)8 to base 16 Number Systems and Codes
Base Conversion from base 16 • Convert (9F2)16 to base 2 • Convert (9F2)16 to base 8 • Convert (9F2)16 to base 10 Number Systems and Codes
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. Number Systems and Codes
Convert Base 10 to Base r Convert (174)10 to base 8 Therefore (174)10 = (256)8 Number Systems and Codes
Convert Base 10 to Base r Convert (0.275)10 to base 8 Therefore (0.275)10 = (0.21463)8 Number Systems and Codes
Convert Base 10 to Base r Convert (0.68475)10 to base 2 Therefore (0.68475)10 = (0.10101)2 Number Systems and Codes
Signed Number Representation There are 3 systems to represent signed numbers in binary number system: • Signed-magnitude • 1's complement • 2's complement Number Systems and Codes
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. Number Systems and Codes
Signed-magnitude system Number Systems and Codes
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 Number Systems and Codes
Example of 1's Complement For example in a 4-bit system, 0101 represents +5 and 1010 represents 5 Number Systems and Codes
1's Complement system Number Systems and Codes
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 Number Systems and Codes
Example of 2's Complement For example in a 4-bit system, 0101 represents +5 and 1011 represents 5 Number Systems and Codes
2's Complement system Number Systems and Codes
Addition and Subtraction in Signed and Magnitude Number Systems and Codes
Addition and Subtraction in 1’s Complement Number Systems and Codes
Addition and Subtraction in2’s Complement Number Systems and Codes
Overflow Conditions Carry-incarry-out 0111 1000 5 0101 -5 1011 +3 +0011 -4 +1100 -8 10007 10111 Carry-in = carry-out 0000 1110 +5 0101 -2 1110 +2 +0010 -6 +1010 7 0111-8 11000 Number Systems and Codes
Addition and Subtraction inHexadecimal System Addition Subtraction Number Systems and Codes
Codes • Decimal codes • Gray code • Error detection code • ASCII code Number Systems and Codes
Decimal codes Number Systems and Codes
Gray Code Number Systems and Codes
Error detection code Number Systems and Codes
Error detection code Number Systems and Codes
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 Number Systems and Codes
Assignment 1 Page 74 • 1.1: Only A+B and AB (a), (c), (f), and (g) • 1.2: Only A+B and AB (a), (c) • 1.3: Only A+B and AB (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) Number Systems and Codes