Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1

2 Number Systems (1)  Positional Notation N = (a n-1 a n-2... a 1 a 0. a -1 a 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 a 0 x r 0 + a -1 x r a -m x r -m = (1.2)  N = (251.41) 10 = 2 x x x x x 10 -2

3 Number Systems (2)  Binary numbers  Digits = {0, 1}  ( ) 2 = 1 x x x x x x 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 x x 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 x x x 16 0 = (46,687) 10

4 Number Systems (3)  Important Number Systems (Table 1.1)

5 Powers of Decimal Equivalent ,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 ,023 2,047 4,095 8,191 16,383 32,767 65,535 Binary Hexadecimal 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  Evaluate the series using base B arithmetic.  Examples:  (11010) 2 ® ( ? ) 10 N = 1          0 = (16) 10 + (8) (2) = (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 = ( … ) 8 MSD ¬   ¬   ¬   8 LSD ¬   8 …  (0.479) 10 = ( … ) 2 MSD ¬   ¬   ¬   2 LSD ¬   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 = … = ( … ) 10 (b) Convert from base 10 to base 11 using radix divide and multiply method: ¬   ¬   ¬   11 N 11 = ( … ) 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  ( ) 2 = (127.4) 8 (group bits by 3)  ( ) 2 = (B65F) 16 (group bits by 4)

15 Binary addition = = = = 10 = 0 + carry of 1 into next position = 11 = 1 + carry of 1 into next position ABSUMCO 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 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 = = = = 1 ต้องยืมจากหลักที่สูงกว่า มา 1 ABSUBBO 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 FULL Subtractor A B SUB BO BI

21 REPRESENTING UNSIGNED NUMBERS (Absolute value) A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 =00H B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 =FFH

22 REPRESENTING SIGNED NUMBERS in sign-magnitude form A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 = SIGN BIT Magnitude = B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 = SIGN BIT Magnitude = 52 10

23 REPRESENTING SIGNED NUMBERS in the 2 ’ S-complement system A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 = SIGN BIT True binary B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 = SIGN BIT 2 ’ s complement

24 Range of Sign-Magnitude Numbers A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 =+1 10 SIGN BIT B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 = A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 = B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 =-1 10

25 Range of Sign-Magnitude Numbers A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 =+1 10 SIGN BIT B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 = A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 = 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 = ’s complement X 3 X 2 X 1 X 0 = ’s complement 2’s complement = 1’s complement + 1 X3X3 X3X3 X2X2 X2X2 X1X1 X1X1 X0X0 X0X0

28 Positive and Negative Numbers MagnitudePositiveNegative

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 ____ ____ ___ ___ 14H DDH ___H BDH ___H 70H ___H 6EH _____H +20 ___ +47 ___ -125 ___ -19, F E B2DA

31 CASE 4 Both negative ADDITION CASE 1 Both positive ’s complement arithmetic CASE 2 Positive and smaller negative (-68) CASE 3 Positive and larger negative (- 115) (-78 )

32 SUBTRACTION CASE 1 Both positive ’s complement arithmetic CASE 2 Positive and smaller negative (- 16) (+27) CASE 3 Positive and larger negative (+ 108) CASE 4 Both negative (+78 )

33 INVERT A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 Y7Y7 Y6Y6 Y5Y5 Y4Y4 Y3Y3 Y2Y2 Y1Y1 Y0Y A 7 -A Y 7 -Y Y 7 -Y 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 Binary adder-subtractor diagram S8S8

35 Binary adder-subtractor circuit ADD/


Download ppt "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."

Similar presentations


Ads by Google