Digital Logic Circuit Number System PDF

Summary

These lecture notes cover digital logic circuits, number systems, and conversion methods between decimal, binary, octal, and hexadecimal. The document includes examples and formulas.

Full Transcript

Digital Logic Circuit Number System Mak(Prof. KIM) A303 010 6201 2453 [email protected] 1 Lecture table of contents Number Systems Number Base Conversions Integer Representation Co...

Digital Logic Circuit Number System Mak(Prof. KIM) A303 010 6201 2453 [email protected] 1 Lecture table of contents Number Systems Number Base Conversions Integer Representation Complement Complement Operation Real Number Representation 2 Decimal Number System Decimal number system was used because the human fingers were ten Base (also called radix) = 10 10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } Digit Position Integer & fraction 5 1 2 7 4 Digit Weight (ex: 512.74) 100 10 1 0.1 0.01 Position Weight = (Base) 500 10 2 0.7 0.04 Magnitude Sum of “Digit x Weight ” (512.74)10 Formal Notation 3 Binary Number System Base = 2 2 digits { 0, 1 }, called binary digits or “bits” Weights (ex: 101.01) 1 0 1 0 1 Position Weight = (Base) 4 2 1 1/2 1/4 Magnitude 2 1 0 -1 -2 1 *22+0 *21+1 *20+0 *2-1+1 *2-2 Sum of “Bit x Weight ” 101.01 (2) = 5.25 (10) =(5.25)10 Formal Notation (101.01)2 Groups of bits 4 bits = Nibble 1011 8 bits = Byte 11000101 4 5 Exercise) Converting binary to decimal 6 Decimal (Integer) to Binary Conversion Divide the number by the ‘Base’ (=2) Take the remainder (either 0 or 1) as a coefficient Take the quotient and repeat the division Example: (13)10 Quotient Remainder Coefficient 13 / 2 = 6 1 a0 = 1 6 /2= 3 0 a1 = 0 3 /2= 1 1 a2 = 1 1 /2= 0 1 a3 = 1 Answer: (13)10 = (a3 a2 a1 a0)2 = (1101)2 MSB LSB 7 Decimal (Integer) to Binary Conversion Mak’s Shortcut 2 to the Power of n n 2n n 2n 0 20=1 8 28=256 1 21=2 9 29=512 2 22=4 10 210=1024 Kilo 3 23=8 11 211=2048 4 24=16 12 212=4096 5 25=32 20 220=1M Mega 6 26=64 30 230=1G Giga 7 27=128 40 240=1T Tera 9 Decimal (Fraction) to Binary Conversion Multiply the number by the ‘Base’ (=2) Take the integer (either 0 or 1) as a coefficient Take the resultant fraction and repeat the multply Example: (0.625)10 Integer Fraction Coefficient 0.625 * 2 = 1. 25 a-1 = 1 0.25 * 2 = 0. 5 a-2 = 0 0.5 *2= 1. 0 a-3 = 1 Answer: (0.625)10 = (0.a-1 a-2 a-3)2 = (0.101)2 MSB LSB 10 Decimal (Fraction) to Binary Conversion Mak’s Shortcut 0.687510 0. 1/2 1/4 1/8 1/16.5.25.125.0625 …………….. 0.10112 = 0.5 + 0.125 + 0.0625 = 0.687510 11 Decimal to Binary Conversion 12 Decimal to Binary Conversion Shortcut ppt 11 --> 0.687510 13 Exercise) Converting decimal to binary 14 Octal Number System Base = 8 8 digits { 0, 1, 2, 3, 4, 5, 6, 7 } 64 8 1 1/8 1/64 Weights 5 1 2 7 4 Position Weight = (Base) 2 1 0 -1 -2 Magnitude 5 *82+1 *81+2 *80+7 *8-1+4 *8-2 Sum of “Digit x Weight ” =(330.9375)10 Formal Notation (512.74)8 15 The next month is October. The root Oct means 8 so why is it October? The change to a 12-month year began in ancient Rome. Initially, the Roman calendar consisted of 10 months (about 298 days), but in 713 BC, the second king of Rome, Numa Pompilius, added two months of winter, making the year 12 months long. This change was related to astronomical reasons. It takes about 365.25 days for the Earth to orbit the Sun. Dividing this period into 12 months results in each month being about 30 days long, which roughly aligns with the lunar cycle. This structure was designed to accommodate seasonal changes and the convenience of daily life. 16 The next month is October. The root Oct means 8 so why is it October? Ancient Rome used March to December. But, today we use January, February, March, April, May, June, July, August, September, October, November, December. January was added to honor Janus, the god of beginnings, and February was named after the purification festival Februa. Originally, these two months were at the end of the year, but they were later moved to the beginning to better reflect the start of the new year. I'm sorry if you were more sleepy. 17 Hexadecimal Number System Base = 16 16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F } Weights 256 16 1 1/16 1/256 Position Weight = (Base) 1 E 5 7 A 2 1 0 -1 -2 Magnitude 1 *162+14 *161+5 *160+7 *16-1+10 *16-2 Sum of “Digit x Weight ” =(485.4765625)10 Formal Notation (1E5.7A)16 The hexadecimal system uses six additional alphabets, from A to F, in addition to the digits 0 through 9 used in the decimal system to express numbers. Be careful because you sometimes mistake A for 11. A is definitely 10. 18 Try solving the problem by referring to the answer. Use the calculator on your mobile phone because it can take a long time to calculate. 19 Decimal to Octal Conversion Example: (175)10 Quotient Remainder Coefficient 175 / 8 = 21 7 a0 = 7 21 / 8 = 2 5 a1 = 5 2 /8= 0 2 a2 = 2 Answer: (175)10 = (a2 a1 a0)8 = (257)8 Example: (0.3125)10 Integer Fraction Coefficient 0.3125 * 8 = 2. 5 a-1 = 2 0.5 *8= 4. 0 a-2 = 4 Answer: (0.3125)10 = (0.a-1 a-2 a-3)8 = (0.24)8 20 Decimal to Octal Conversion 21 Decimal to Octal Conversion (repeating decimal) 22 Decimal to Hexadecimal Conversion Caution! Hexadecimal 11 should be written as B. It is wrong to write 411, it should be written as 4B. 23 Decimal to Hexadecimal Conversion (repeating decimal or recurring decimal) 24 Tip As mentioned earlier, these methods are cumbersome in the calculation process and likely to make mistakes. Therefore, it is easy to convert the conversion between decimal and octal or hexadecimal numbers through binary, as shown in the 34- page picture. Because the converting between binary and octal or hexadecimal is very easy. 25 Number System Q) Humans use decimal and digital systems use binary, but why are octal and hexadecimal mentioned? R) Binary numbers are difficult for humans to read, inconvenient to use, and require many bits to express numbers. For this reason, we use octal and hexadecimal, which are close to the decimal system used by humans and can be easily converted to binary. 26 Supplemental Video - Decimal to Binary Conversion(09:53) 27 Introduction to Number Systems(05:23) 28 Binary − Octal Conversion Octal Binary 8= 23 0 000 Each group of 3 bits represents an octal digit 1 001 2 010 Assume Zeros Example: 3 011 ( 1 0 1 1 0. 0 1 )2 4 100 5 101 6 110 ( 2 6. 2 )8 7 111 Works both ways (Binary to Octal & Octal to Binary) 29 Binary − Octal Conversion When separating into three digits, the integer part should be separated to the left and the real part to the right based on the decimal point. But, the separated binary value has a weight of 4 2 1 regardless of the integer part real number part. 30 Binary − Hexadecimal Conversion 16 = 24 Hex Binary 0 0000 Each group of 4 bits represents a 1 2 0001 0010 hexadecimal digit 3 0011 4 0100 Assume Zeros 5 0101 6 0110 Example: 7 0111 ( 1 0 1 1 0. 0 1 )2 8 1000 9 1001 A 1010 B 1011 C 1100 (1 6. 4 )16 D 1101 E 1110 F 1111 Works both ways (Binary to Hex & Hex to Binary) 31 Hexadecimal to Binary Conversion Octal to Binary Conversion 32 Octal − Binary - Hexadecimal Conversion Convert to Binary as an intermediate step Example: ( 2 6. 2 )8 Assume Zeros Assume Zeros ( 0 1 0 1 1 0. 0 1 0 )2 (1 6. 4 )16 Works both ways (Octal to Hex & Hex to Octal) 33 34 35 Hexadecimal to Octal & Octal to Hexadecimal (05:11) 36 Exercise) 37 Exercise) 38 Exercise) 39 Exercise) 40 Homework #1 1. Why don't we use decimal inside the computer? 2. Convert the following decimal numbers to binary, octal, and hexadecimal. 1) 892 2) 783.8125 3) 48.3515625 4) 0.0078125 5) 52.7578125 6) 47.9 3. Convert the following octal to binary and hexadecimal, and hexadecimal to binary and octal. 1) 21368 2) 67438 3)5436.158 4) 0.021368 5) 102316 6) 6BCF16 7) F42016 8) 330F.FC16 9) 0.0E3416 41 Homework #2 4. Fill in the blanks in the following table. 42 Dashain? The Nepalese festival ‘Dashain' is these days, right? While preparing for the lecture, I was curious about Nepalese festivals similar to holidays such as Chuseok in Korea. I saw pictures of people with 'Tika' and ‘Jamara' on their foreheads, and I saw food called ‘Dal Bhat' and ‘Momos’. Is there anyone who can do "Jamara" for me in the next class? 43 Integer Representation (3 methods) MSB is sign bit. (Only 0 or 1 can be stored in memory) +: 0 -: 1 +4, -4 representation (using 4 bits) 0100, 1100 : signed - magnitude method 0100, 1011 : signed - 1’s complement method 0100, 1100 : signed - 2’s complement method 44 Integer Representation ➔ Positive integer representations are all the same. ➔ Negative integer representation is different. ➔ Signed - magnitude method is the same way we used to use it. ➔ Signed - 1’s complement method is easy to complement representation. (replace all the bits 0 -> 1, 1 -> 0 : negative integer only) ➔ Signed - 2’s complement method is used on the computer. next page IEEE 754 standard bias : using to 127 or 1023 exponent expressed = bias + binary exponent value sign : 1 bit bias 127 : 8 bit mantissa(1.xxx ) : 23 bit 127 + 6 1. (omission) + (01111111 + 00000110) (1.0001011011) 0 10000101 00101110110000000000000 “1.” Omission Floating Point Number Representation The exponent also has a positive exponent and a negative exponent, but there is no sign bit for the exponent. In floating-point representation, a bias is used to allow both positive and negative exponents. (It is expressed by adding a bias value to the negative exponents.) This simplifies the comparison and arithmetic operations by ensuring that the exponent field is always non-negative. The reason for ‘1.’ omission is to promise to omit 1 to express a larger or smaller number as much as the omissing bits. ❑ Decimal number -0.2 : single precision −0.2 = −0.00110011001100110011001...(2) = −1.10011001100110011001...(2)  2−3 = −1.10011001100110011001...  2−11( 2) sign : 1 bit bias 127 : 8 bit mantissa(1.xxx ) : 23 bit 127 + (- 3) 1.을 생략한 가수 - (01111111 + (- 00000011) (1.10011001100110011001100) 1 01111100(124) 10011001100110011001100 “1.” Omission Floating Point Number Representation 69 Homework #3 5. Use eight bits to represent the following decimal numbers as 1’ and 2’ complements. 1) +18 2) +115 3) +79 4) -49 5) -3 6) -100 6. Calculate the next decimal number by converting it into an 8-bit 2’ complement. 1) 78 - 34 2) 98 - 100 3) -56 - 34 4) 59 - 11 5) 98 – 59 6) -88 - 105 70 Thank you! See you next time. Mak(Prof. KIM) A303 010 6201 2453 [email protected] 71

Use Quizgecko on...
Browser
Browser