Download presentation
Presentation is loading. Please wait.
Published byBaylee Penniman Modified over 10 years ago
2
Number Systems (1) Positional Notation N = (a n-1 a n-2... a 1 a 0. a -1 a -2... a -m ) r (1.1) where. = radix point r = radix or base n = number of integer digits to the left of the radix point m = number of fractional digits to the right of the radix point a n-1 = most significant digit (MSD) a -m = least significant digit (LSD) Polynomial Notation (Series Representation) N = a n-1 x r n-1 + a n-2 x r n-2 +... + a 0 x r 0 + a -1 x r -1... + a -m x r -m = (1.2) N = (251.41) 10 = 2 x 10 2 + 5 x 10 1 + 1 x 10 0 + 4 x 10 -1 + 1 x 10 -2
3
Number Systems (2) Binary numbers Digits = {0, 1} (11010.11) 2 = 1 x 2 4 + 1 x 2 3 + 0 x 2 2 + 1 x 2 1 + 0 x 2 0 + 1 x 2 -1 + 1 x 2 -2 = (26.75) 10 1 K (kilo) = 2 10 = 1,024, 1M (mega) = 2 20 = 1,048,576, 1G (giga) = 2 30 = 1,073,741,824 Octal numbers Digits = {0, 1, 2, 3, 4, 5, 6, 7} (127.4) 8 = 1 x 8 2 + 2 x 8 1 + 7 x 8 0 + 4 x 8 -1 = (87.5) 10 Hexadecimal numbers Digits = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F} (B65F) 16 = 11 x 16 3 + 6 x 16 2 + 5 x 16 1 + 15 x 16 0 = (46,687) 10
4
Number Systems (3) Important Number Systems (Table 1.1)
5
Powers of 2 2 0 2 12 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10 2 11 2 12 2 13 2 14 2 15 2 16 Decimal Equivalent 1 2 4 8 16 32 64 128 256 512 1,024 2,048 4,096 8,192 16,384 32,768 65,536 Abbreviation 1K 2K 4K 8K 16K 32K 64K
6
Decimal-Binary Equivalences Decimal 1 3 7 15 31 63 127 255 511 1,023 2,047 4,095 8,191 16,383 32,767 65,535 Binary 1 11 111 1111 1 1111 11 1111 111 1111 1111 1 1111 1111 11 1111 1111 111 1111 1111 1111 1111 1111 1 1111 1111 1111 11 1111 1111 1111 111 1111 1111 1111 1111 1111 Hexadecimal 1 3 7 F 1F 3F 7F FF 1FF 3FF 7FF FFF 1FFF 3FFF 7FFF FFFF
7
Base Conversion (1) Series Substitution Method Expanded form of polynomial representation: N = a n-1 r n-1 + … + a 0 r 0 + a -1 r -1 + … + a -m r -m (1.3) Conversation Procedure (base A to base B) Represent the number in base A in the format of Eq. 1.3. Evaluate the series using base B arithmetic. Examples: (11010) 2 ® ( ? ) 10 N = 1 0 = (16) 10 + (8) 10 + 0 + (2) 10 + 0 = (26) 10 (627) 8 ® ( ? ) 10 N = 6 = (384) 10 + (16) 10 + (7) 10 = (407) 10
8
Base Conversion (2) Radix Divide Method Used to convert the integer in base A to the equivalent base B integer. Underlying theory: (N I ) A = b n-1 B n-1 + … + b 0 B 0 (1.4) Here, b i ’ s represents the digits of (N I ) B in base A. N I b n-1 B n-1 + … + b 1 B 1 + b 0 B 0 ) / B = (Quotient Q 1 : b n-1 B n-2 + … + b 1 B 0 ) + (Remainder R 0 : b 0 ) In general, (b i ) A is the remainder R i when Q i is divided by (B) A. Conversion Procedure 1. Divide (N I ) B by (B) A, producing Q 1 and R 0. R 0 is the least significant digit, d 0, of the result. 2. Compute d i, for i = 1 … n - 1, by dividing Q i by (B) A, producing Q i+1 and R i, which represents d i. 3. Stop when Q i+1 = 0.
9
Base Conversion (3) Examples (315) 10 = (473) 8 (315) 10 = (13B) 16
10
Base Conversion (4) Radix Multiply Method Used to convert fractions. Underlying theory: (N F ) A = b -1 B -1 + b -2 B -2 + … + b -m B -m (1.5) Here, (N F ) A is a fraction in base A and b i ’ s are the digits of (N F ) B in base A. B N F = B (b -1 B -1 + b -2 B -2 + … + b -m B -m ) = (Integer I -1 : b -1 ) + (Fraction F -2 : b -2 B -1 + … + b -m B -(m-1) ) In general, (b i ) A is the integer part I -i, of the product of F -(i+1) (B A ). Conversion Procedure 1. Let F -1 = (N F ) A. 2. Compute digits (b -i ) A, for i = 1 … m, by multiplying F i by (B) A, producing integer I -i, which represents (b -i ) A, and fraction F - (i+1). 3. Convert each digits (b -i ) A to base B.
11
Base Conversion (5) Examples (0.479) 10 = (0.3651 … ) 8 MSD 3.832 ¬ 0.479 8 6.656 ¬ 0.832 8 5.248 ¬ 0.656 8 LSD 1.984 ¬ 0.248 8 … (0.479) 10 = (0.0111 … ) 2 MSD 0.9580 ¬ 0.479 2 1.9160 ¬ 0.9580 2 1.8320 ¬ 0.9160 2 LSD 1.6640 ¬ 0.8320 2 …
12
Base Conversion (6) General Conversion Algorithm Algorithm 1.1 To convert a number N from base A to base B, use (a) the series substitution method with base B arithmetic, or (b) the radix divide or multiply method with base A arithmetic. Algorithm 1.2 To convert a number N from base A to base B, use (a) the series substitution method with base 10 arithmetic to convert N from base A to base 10, and (b) the radix divide or multiply method with decimal arithmetic to convert N from base 10 to base B. Algorithm 1.2 is longer, but easier and less error prone.
13
Base Conversion (7) Example (18.6) 9 = ( ? ) 11 (a) Convert to base 10 using series substitution method: N 10 = 1 9 1 + 8 9 0 + 6 9 -1 = 9 + 8 + 0.666 … = (17.666 … ) 10 (b) Convert from base 10 to base 11 using radix divide and multiply method: 7.326 ¬ 0.666 11 3.586 ¬ 0.326 11 6.446 ¬ 0.586 11 N 11 = (16.736 … ) 11
14
Base Conversion (8) When B = A k Algorithm 1.3 (a) To convert a number N from base A to base B when B = A k and k is a positive integer, group the digits of N in groups of k digits in both directions from the radix point and then replace each group with the equivalent digit in base B (b) To convert a number N from base B to base A when B = A k and k is a positive integer, replace each base B digit in N with the equivalent k digits in base A. Examples (001 010 111. 100) 2 = (127.4) 8 (group bits by 3) (1011 0110 0101 1111) 2 = (B65F) 16 (group bits by 4)
15
Binary addition 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10 = 0 + carry of 1 into next position 1 + 1 + 1 = 11 = 1 + carry of 1 into next position ABSUMCO 0000 0110 1010 1101 HALF ADDER A B SUM CO Carry-Out = SUM =
16
Binary addition Carry-Out = SUM = 1-bit 8 Strings Full Adder with Carry-In and Carry-Out CIABSUMCO 00000 00110 01010 01101 10010 10101 11001 11111 FULL ADDER A B SUM CO CI
17
1-bit 8 Strings Full Adder with Carry-In and Carry-Out Carry-Out = SUM = FULL ADDER A B SUM CO CI
18
Binary addition
19
Binary Subtraction 0 - 0 = 0 1 - 0 = 1 1 - 1 = 0 0 - 1 = 1 ต้องยืมจากหลักที่สูงกว่า มา 1 ABSUBBO 0000 0111 1010 1100 HALF Subtractor A B SUB BO Borrow-Out = SUB =
20
Binary Subtraction Borrow-Out = SUB = 1-bit 8 Strings Full Subtractor with Borrow-In and Borrow -Out BIABSUBBO 00000 00111 01010 01100 10011 10101 11000 11111 FULL Subtractor A B SUB BO BI
21
REPRESENTING UNSIGNED NUMBERS (Absolute value) 00 000000 A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 =00H 11 111111 B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 =FFH
22
REPRESENTING SIGNED NUMBERS in sign-magnitude form. 00 110100 A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 =+52 10 SIGN BIT Magnitude = 52 10 10 110100 B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 =-52 10 SIGN BIT Magnitude = 52 10
23
REPRESENTING SIGNED NUMBERS in the 2 ’ S-complement system. 00 101101 A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 =+45 10 SIGN BIT True binary 11 010011 B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 =-45 10 SIGN BIT 2 ’ s complement
24
Range of Sign-Magnitude Numbers 00 000001 A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 =+1 10 SIGN BIT 01 111111 B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 =+127 10 10 000001 A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 =-127 10 11 111111 B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 =-1 10
25
Range of Sign-Magnitude Numbers 00 000001 A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 =+1 10 SIGN BIT 01 111111 B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 =+127 10 10 000001 A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 =-127 10 11 111111 B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 =-1 10
26
การคอมพลีเมนต์ เลขฐานสอง แบ่งออกเป็น คอมพลีเมนต์ 1 (1 ’ s complement) คอมพลีเมนต์ 2 (2 ’ s complement) การคอมพลีเมนต์เลขฐานสองนี้นำไปใช้ เกี่ยวกับการคำนวณทางไมโครคอมพิวเตอร์ มาก เพราะว่าจะใช้ในลักษณะการลบด้วย วิธีการบวกด้วยคอมพลีเมนต์ สรุป การลบด้วยการบวกด้วยคอมพลีเมนต์ นั้นจะทำนองเดียวกับการคอมพลีเมนต์ เลขฐานสิบ
27
การคอมพลีเมนต์ เลขฐานสอง X 3 X 2 X 1 X 0 = 1000 1’s complement X 3 X 2 X 1 X 0 = 0111 2’s complement 2’s complement = 1’s complement + 1 X3X3 X3X3 X2X2 X2X2 X1X1 X1X1 X0X0 X0X0
28
Positive and Negative Numbers -8 -7 -6 -5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5 +6 +7 1000 1001 1010 1011 1100 1101 1110 1111 0000 0001 0010 0011 0100 0101 0110 0111 MagnitudePositiveNegative 1234567812345678 0001 0010 0011 0100 0101 0110 0111 - 1111 1110 1101 1100 1011 1010 1001 1000
29
2 ’ S-complement representation summary Positive numbers always have a sign bit of 0, and negative numbers always have a sign bit of 1. Positive numbers are stored in sign-magnitude form. Negative numbers are stored as 2’s complements. Taking the 2’s complement is equivalent to a sign change.
30
Example : Binary contentsHexadecimal contentsDecimal contents 0001 0100 ____ 1001 1110 ____ ___ ___ 14H DDH ___H BDH ___H 70H ___H 6EH _____H +20 ___ +47 ___ -125 ___ -19,750 1101 -35 0010 1111 2F 1011 1101 -67 9E -98 0111 0000 +112 1000 0011 83 0110 1110 110 1011 0010 1101 1010 B2DA
31
CASE 4 Both negative. -43 -78 ADDITION CASE 1 Both positive. +83 +16 2’s complement arithmetic 0101 0011 0001 0000 83 0101 0011 + 16 + 0001 0000 99 0110 0011 CASE 2 Positive and smaller negative. +125 -68 0111 1101 1011 1100 125 0111 1101 +(-68) +1 011 1100 57 1 0011 1001 CASE 3 Positive and larger negative. +37 -115 37 0010 0101 +(- 115) + 1000 1101 -78 1011 0010 1101 0101 1011 0010 -43 1101 0101 +(-78 ) + 1011 0010 -121 1 1000 0111 0010 0101 1000 1101
32
SUBTRACTION CASE 1 Both positive. +83 +16 2’s complement arithmetic 0101 0011 0001 0000 CASE 2 Positive and smaller negative. +68 -27 83 0101 0011 +(- 16) + 1111 0000 67 1 0100 0011 0100 1110 0101 68 0100 +(+27) + 0001 1011 95 0101 1111 CASE 3 Positive and larger negative. +14 -108 14 0000 1110 +(+ 108) + 0110 1100 122 0111 1010 1101 0101 1011 0010 CASE 4 Both negative. -43 -78 -43 1101 0101 +(+78 ) + 0100 1110 35 1 0010 0011 0000 1110 1001 0100
33
INVERT A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 Y7Y7 Y6Y6 Y5Y5 Y4Y4 Y3Y3 Y2Y2 Y1Y1 Y0Y0 001001 A 7 -A 0 0110 1110 Y 7 -Y 0 0110 1110 Y 7 -Y 0 1001 0001 INVLOGIC Controlled inverter
34
ADD/SUB A7A7 A 6 A5A5 A4A4 A 3 A 2 A 1 A0A0 S7S7 S 6 S5S5 S4S4 S 3 S2S2 S1S1 S0S0 B7B7 B 6 B5B5 B4B4 B 3 B 2 B 1 B 0 ADDITION A 7 A 6 A 5 A 4 A 3 A 2 A 1 A0A0 +B 7 B 6 B 5 B 4 B 3 B 2 B 1 B0B0 S 7 S 6 S 5 S 4 S 3 S 2 S 1 S0S0 SUBTRACTION A 7 A 6 A 5 A 4 A 3 A 2 A 1 A 0 +B 7 B 6 B 5 B 4 B 3 B 2 B 1 B 0 +1 S 7 S 6 S 5 S 4 S 3 S 2 S 1 S 0 - - - - Binary adder-subtractor diagram S8S8
35
Binary adder-subtractor circuit. 7483 ADD/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.