250 likes | 451 Views
DKT 122/3 DIGITAL SYSTEM 1. WEEK #3 NUMBER SYSTEMS, OPERATION & CODES (PART 2). Signed Numbers. Arithmetic Operations - Addition. Add the 2 signed numbers and discard any final carry bit. Example: 11111011 + 11110111 11111011 + 11110111 1 11110010. Discard carry bit.
E N D
DKT 122/3DIGITAL SYSTEM 1 WEEK #3 NUMBER SYSTEMS, OPERATION & CODES (PART 2)
Signed Numbers Arithmetic Operations- Addition Add the 2 signed numbers and discard any final carry bit Example: 11111011 + 11110111 11111011 + 11110111 1 11110010 Discard carry bit
2’s complement of subtrahend Signed Numbers (Cont.) Arithmetic Operations- Subtraction • take the 2’s complement of the subtrahend and add to the minuend • discard any final carry bit Example: 00001000 – 00000011 minuend subtrahend 00001000 00001000 - 00000011 + 11111101 1 00000101 Discard carry
Number System (Hexadecimal) • Base 16 system • Uses digits0-9& lettersA,B,C,D,E,F • Groups of four bitsrepresent eachbase 16 digit
Number System (Hex) (Cont.) Hexadecimal to Decimal Conversion Convert 3B4F16 to its decimal equivalent: Hex digits 3 B 4 F x x x x Positional Values 163 162 161 160 12288 +2816 +64 +15 Products 15,18310
Number System (Hex) (Cont.) Decimal to Hexadecimal Conversion Convert 83010 to its hexadecimal equivalent: 830 / 16 = 51 R 14 51 / 16 = 3 R 3 3 / 16 = 0 R 3 E in Hex 33E16
Number System (Hex) (Cont.) Binary to Hexadecimal Conversion Grouping the binary position in 4-bit groups, starting from the least significant position.
Number System (Hex) (Cont.) Binary to Hexadecimal Conversion Example Convert 0101011010101110011010102 to hex using the 4-bit substitution code : 0101 0110 1010 1110 0110 1010 5 6 A E 6 A
Solve this.. • Convert hexadecimal number 2316, 8D16and EB16 to decimal • Convert decimal number 5210, 28410 and 289010to hexadecimal • Convert hexadecimal number 3816 and 5C816 to binary • Convert binary number 1110 and 10111 to hexadecimal
Numbering System (Octal) • Also known as theBase 8 System • Uses digits0 - 7 • Readily converts to binary • Groups of three (binary) digits can be used to represent each octal digit • Also uses multiplication and division algorithms for conversion to and from base 10
Numbering System (Octal) (Cont.) Octal to Decimal Conversion Convert 6538 to its decimal equivalent Octal Digits 6 5 3 x x x Positional Values 82 81 80 Products 384 + 40 + 3 42710
Numbering System (Octal) (Cont.) Decimal to Octal Conversion Use the repeated division-by-8 method Example Convert 42710 to its octal equivalent 427 / 8 = 53R 3 LSB53 / 8 = 6R 5 6 / 8 = 0R 6 MSB 6538
Numbering System (Octal) (Cont.) Octal to Binary Conversion Each octal number converts to 3 binary digits Example Convert 6538 to binary 6 5 3 Substitute numbers with 3-binary digits 110 101 011
Numbering System (Octal) (Cont.) Binary to Octal Conversion Grouping the binary position in groups of 3 starting at the least significant position. Example Convert the binary numbers 110101 to octal • 1 1 0 1 0 1 • 6 5 658
Solve this.. Convert octal number 648, 5578 and 10248 to decimal Convert decimal number 4610, 10010 and 21910to octal Convert octal number 1018 and 3218to binary Convert binary number 101010 and 110111 to octal
Digital Codes - BCD • BCD (Binary Coded Decimal) Code • Represent each of the 10 decimal digits (0~9) as a 4-bit binary code. Example Convert 15 to BCD. 1 5 0001 0101BCD
Digital Codes – BCD (Cont.) Addition Step 1: Add the two BCD numbers, using the rules for binary addition Step 2: If a 4-bit sum is equal to or less than 9, it is a valid BCD number Step 3: If a 4-bit sum is greater than 9 / if a carry out is generated, it is an invalid BCD result. Add 6 (0110) to the 4-bit sum
Digital Codes – BCD (Cont.) Addition – Valid number Example: 0 0 1 1 + 0 1 0 0 0 1 1 1(Valid BCD number)
Digital Codes – BCD (Cont.) Addition – Not valid number Example: 1 0 0 1 + 0 1 0 0 1 1 0 1 (Invalid BCD number coz >9) + 0 1 1 0(Add 6) 0 0 0 1 0 0 1 1(Valid BCD number) 1 3
Digital Codes - ASCII • ASCII (American Standard Code for Information Interchange) Code • Used to translate from the keyboard characters to computer language
Digital Codes - Gray • Gray Code • Only 1 bit changes • Can’t be used in arithmetic circuits • Exhibits only a single change from one code word to the next in sequence • Need to know how to convert binary to Gray and vice versa.
Digital Codes – Gray (Cont.) Convert binary number 10110 to gray code. 1 0 1 1 0 1 1 1 0 1 Gray Codes Binary to Gray Conversion + + + +
Digital Codes – Gray (Cont.) Convert gray code 10110 to binary. 1 0 1 1 0 1 1 0 1 1 Binary Gray to Binary Conversion + + + +
Solve this.. (a) Convert binary number 11111 to gray code. (b) Convert gray code 11011 to binary. Answer : ? Answer : ? END