Presentation is loading. Please wait.

Presentation is loading. Please wait.

IT101: INFORMATION TECHNOLOGY FUNDAMENTALS 1 Edited By Dr. Ahmed Abo-Bakr Information Technology Dept. Faculty of Computers & Information.

Similar presentations


Presentation on theme: "IT101: INFORMATION TECHNOLOGY FUNDAMENTALS 1 Edited By Dr. Ahmed Abo-Bakr Information Technology Dept. Faculty of Computers & Information."— Presentation transcript:

1

2 IT101: INFORMATION TECHNOLOGY FUNDAMENTALS 1 Edited By Dr. Ahmed Abo-Bakr Information Technology Dept. Faculty of Computers & Information

3 NUMBER SYSTEMS

4 Common Number Systems SystemBaseSymbols Used by humans? Used in computers? Decimal100, 1, … 9YesNo Binary20, 1NoYes Octal80, 1, … 7No Hexa- decimal 160, 1, … 9, A, B, … F No

5 Quantities/Counting (1 of 3) DecimalBinaryOctal Hexa- decimal 0000 1111 21022 31133 410044 510155 611066 711177

6 Quantities/Counting (2 of 3) DecimalBinaryOctal Hexa- decimal 81000108 91001119 10101012A 11101113B 12110014C 13110115D 14111016E 15111117F

7 Quantities/Counting (3 of 3) DecimalBinaryOctal Hexa- decimal 16100002010 17100012111 18100102212 19100112313 20101002414 21101012515 22101102616 23101112717 Etc.

8 Conversion Among Bases  The possibilities: Hexadecimal DecimalOctal Binary

9 Quick Example 25 10 = 11001 2 = 31 8 = 19 16 Base

10 Decimal to Decimal (just for fun) Hexadecimal DecimalOctal Binary

11 125 10 =>5 x 10 0 = 5 2 x 10 1 = 20 1 x 10 2 = 100 125 Base Weight

12 Binary to Decimal Hexadecimal DecimalOctal Binary

13 Binary to Decimal  Technique  Multiply each bit by 2 n, where n is the “weight” of the bit  The weight is the position of the bit, starting from 0 on the right  Add the results

14 Example 101011 2 => 1 x 2 0 = 1 1 x 2 1 = 2 0 x 2 2 = 0 1 x 2 3 = 8 0 x 2 4 = 0 1 x 2 5 = 32 43 10 Bit “0”

15 Octal to Decimal Hexadecimal DecimalOctal Binary

16 Octal to Decimal  Technique  Multiply each bit by 8 n, where n is the “weight” of the bit  The weight is the position of the bit, starting from 0 on the right  Add the results

17 Example 724 8 => 4 x 8 0 = 4 2 x 8 1 = 16 7 x 8 2 = 448 468 10

18 Hexadecimal to Decimal Hexadecimal DecimalOctal Binary

19 Hexadecimal to Decimal  Technique  Multiply each bit by 16 n, where n is the “weight” of the bit  The weight is the position of the bit, starting from 0 on the right  Add the results

20 Example ABC 16 =>C x 16 0 = 12 x 1 = 12 B x 16 1 = 11 x 16 = 176 A x 16 2 = 10 x 256 = 2560 2748 10

21 Decimal (Integer) to Binary Conversion Hexadecimal DecimalOctal Binary

22 Decimal (Integer) to Binary Conversion  Technique  Divide by two, keep track of the remainder  First remainder is bit 0 (LSB, least-significant bit)  Second remainder is bit 1  Etc.

23 Decimal (Integer) to Binary Conversion DDivide the number by the ‘Base’ (=2) TTake the remainder (either 0 or 1) as a coefficient TTake the quotient and repeat the division Example: ( 13 ) 10 QuotientRemainder Coefficient Answer: (13) 10 = (a 3 a 2 a 1 a 0 ) 2 = (1101) 2 MSB LSB 13 / 2 = 61 a 0 = 1 6 / 2 = 30 a 1 = 0 3 / 2 = 11 a 2 = 1 1 / 2 = 01 a 3 = 1

24 Example 125 10 = ? 2 2 125 62 1 2 31 0 2 15 1 2 7 1 2 3 1 2 1 1 2 0 1 125 10 = 1111101 2

25 Decimal (Fraction) to Binary Conversion  Decimal to decimal (just for fun) 3.14 =>4 x 10 -2 = 0.04 1 x 10 -1 = 0.1 3 x 10 0 = 3 3.14

26 Decimal (Fraction) to Binary Conversion  Binary to decimal 10.1011 => 1 x 2 -4 = 0.0625 1 x 2 -3 = 0.125 0 x 2 -2 = 0.0 1 x 2 -1 = 0.5 0 x 2 0 = 0.0 1 x 2 1 = 2.0 2.6875

27 Decimal (Fraction) to Binary Conversion MMultiply the number by the ‘Base’ (=2) TTake the integer (either 0 or 1) as a coefficient TTake the resultant fraction and repeat the operation Example: ( 0.625 ) 10 IntegerFraction Coefficient Answer: (0.625) 10 = (0.a -1 a -2 a -3 ) 2 = (0.101) 2 MSB LSB 0.625 * 2 = 1. 25 0.25 * 2 = 0. 5 a -2 = 0 0.5 * 2 = 1. 0 a -3 = 1 a -1 = 1

28 Decimal (Fraction) to Binary Conversion  Decimal to binary 3.14579.14579 x 2 0.29158 x 2 0.58316 x 2 1.16632 x 2 0.33264 x 2 0.66528 x 2 1.33056 etc. 11.001001...

29 Octal to Binary Hexadecimal DecimalOctal Binary

30 Octal to Binary  Technique  Convert each octal digit to a 3-bit equivalent binary representation

31 Example 705 8 = ? 2 7 0 5 111 000 101 705 8 = 111000101 2

32 Hexadecimal to Binary Hexadecimal DecimalOctal Binary

33 Hexadecimal to Binary  Technique  Convert each hexadecimal digit to a 4-bit equivalent binary representation

34 Example 10AF 16 = ? 2 1 0 A F 0001 0000 1010 1111 10AF 16 = 0001000010101111 2

35 Decimal to Octal Conversion Hexadecimal DecimalOctal Binary

36 Decimal to Octal Conversion  Technique  Divide by 8  Keep track of the remainder

37 Decimal to Octal Conversion Example: ( 175 ) 10 QuotientRemainder Coefficient Answer: (175) 10 = (a 2 a 1 a 0 ) 8 = (257) 8 175 / 8 = 217 a 0 = 7 21 / 8 = 25 a 1 = 5 2 / 8 = 02 a 2 = 2 Example: ( 0.3125 ) 10 IntegerFraction Coefficient Answer: (0.3125) 10 = (0.a -1 a -2 a -3 ) 8 = (0.24) 8 0.3125 * 8 = 2. 5 0.5 * 8 = 4. 0 a -2 = 4 a -1 = 2

38 Example 1234 10 = ? 8 8 1234 154 2 8 19 2 8 2 3 8 0 2 1234 10 = 2322 8

39 Decimal to Hexadecimal Hexadecimal DecimalOctal Binary

40 Decimal to Hexadecimal  Technique  Divide by 16  Keep track of the remainder

41 Example 1234 10 = ? 16 1234 10 = 4D2 16 16 1234 77 2 16 4 13 = D 16 0 4

42 Binary − Octal Conversion Hexadecimal DecimalOctal Binary

43 Binary − Octal Conversion  Technique  Group bits in threes, starting on right  Convert to octal digits

44 Example 1011010111 2 = ? 8 1 011 010 111 1 3 2 7 1011010111 2 = 1327 8

45 Binary − Octal Conversion  8 = 2 3  Each group of 3 bits represents an octal digit OctalBinary 00 0 0 10 0 1 20 1 0 30 1 1 41 0 0 51 0 1 61 1 0 71 1 1 Example: ( 1 0 1 1 0. 0 1 ) 2 ( 2 6. 2 ) 8 Assume Zeros Works both ways (Binary to Octal & Octal to Binary)

46 Binary − Hexadecimal Conversion Hexadecimal DecimalOctal Binary

47 Binary − Hexadecimal Conversion  Technique  Group bits in fours, starting on right  Convert to hexadecimal digits

48 Example 1010111011 2 = ? 16 10 1011 1011 2 B B 1010111011 2 = 2BB 16

49 Binary − Hexadecimal Conversion  16 = 2 4  Each group of 4 bits represents a hexadecimal digit HexBinary 00 0 10 0 0 1 20 0 1 0 30 0 1 1 40 1 0 0 50 1 60 1 1 0 70 1 1 1 81 0 0 0 91 0 0 1 A1 0 B1 0 1 1 C1 1 0 0 D1 1 0 1 E1 1 1 0 F1 1 Example: ( 1 0 1 1 0. 0 1 ) 2 ( 1 6. 4 ) 16 Assume Zeros Works both ways (Binary to Hex & Hex to Binary)

50 Octal − Hexadecimal Conversion Hexadecimal DecimalOctal Binary

51 Octal − Hexadecimal Conversion  Convert to Binary as an intermediate step Example: ( 0 1 0 1 1 0. 0 1 0 ) 2 ( 1 6. 4 ) 16 Assume Zeros Works both ways (Octal to Hex & Hex to Octal) ( 2 6. 2 ) 8 Assume Zeros

52 Example 1076 8 = ? 16 1 0 7 6 001 000 111 110 2 3 E 1076 8 = 23E 16

53 Hexadecimal to Octal Hexadecimal DecimalOctal Binary

54 Example 1F0C 16 = ? 8 1 F 0 C 0001 1111 0000 1100 1 7 4 1 4 1F0C 16 = 17414 8

55 Exercise – Convert... Don’t use a calculator! DecimalBinaryOctal Hexa- decimal 33 1110101 703 1AF Skip answer Answer

56 Exercise – Convert … DecimalBinaryOctal Hexa- decimal 331000014121 117111010116575 4511110000117031C3 4311101011116571AF Answer

57 Exercise – Convert... Don’t use a calculator! DecimalBinaryOctal Hexa- decimal 29.8 101.1101 3.07 C.82 Skip answer Answer

58 Exercise – Convert … DecimalBinaryOctal Hexa- decimal 29.811101.110011…35.63…1D.CC… 5.8125101.11015.645.D 3.10937511.0001113.073.1C 12.50781251100.1000001014.404C.82 Answer

59 Common Powers (1 of 2)  Base 10 PowerPrefaceSymbol 10 -12 picop 10 -9 nanon 10 -6 micro  10 -3 millim 10 3 kilok 10 6 megaM 10 9 gigaG 10 12 teraT Value.000000000001.000000001.000001.001 1000 1000000 1000000000 1000000000000

60 Common Powers (2 of 2) n2n2n 02 0 =1 12 1 =2 22 2 =4 32 3 =8 42 4 =16 52 5 =32 62 6 =64 72 7 =128 n2n2n 82 8 =256 92 9 =512 102 10 =1024 112 11 =2048 122 12 =4096 202 20 =1M 302 30 =1G 402 40 =1T Mega Giga Tera Kilo  Base 2

61 Example / 2 30 = In the lab… 1. Double click on My Computer 2. Right click on C: 3. Click on Properties

62 Exercise – Free Space  Determine the “free space” on all drives on a machine in the lab Drive Free space BytesGB A: C: D: E: etc.

63 BINARY MATH

64 Review – multiplying powers  For common bases, add powers 2 6  2 10 = 2 16 = 65,536 or… 2 6  2 10 = 64  2 10 = 64k a b  a c = a b+c

65 Decimal Addition Example 3 7 5 8 + 4 6 5 7 1) Add 8 + 7 = 15 Write down 5, carry 1 1 8 11 415 4) Add 3 + 4 + 1 = 8 Write down 8 3) Add 7 + 6 + 1 = 14 Write down 4, carry 1 2) Add 5 + 5 + 1 = 11 Write down 1, carry 1 Add 3758 to 4657:

66 Decimal Addition Explanation 1 1 1 3 7 5 8 + 4 6 5 7 8 4 1 5 What just happened? 1 1 1 (carry) 3 7 5 8 + 4 6 5 7 8 14 11 15 (sum) - 10 10 10 (subtract the base) 8 4 1 5 So when the sum of a column is equal to or greater than the base, we subtract the base from the sum, record the difference, and carry one to the next column to the left.

67 Addition  Decimal Addition 55 55 + 011 = Ten ≥ Base  Subtract a Base 11Carry

68 Binary Addition 4 Possible Binary Addition Combinations: (1) 0(2) 0 +0 +1 00 01 (3) 1(4) 1 +0 +1 01 10 SumCarry Note that leading zeroes are frequently dropped.

69 Binary Addition Rules Rules:  0 + 0 = 0  0 + 1 = 1  1 + 0 = 1(just like in decimal) 1 + 1= 2 10 = 10 2 = 0 with 1 to carry 1 + 1 + 1= 3 10 = 11 2 = 1 with 1 to carry

70 Binary Addition  Column Addition 101111 11110 + 0000111 ≥ (2) 10 111111 = 61 = 23 = 84

71 Binary Addition Example 1 1 1 0 1 1 1 + 0 1 1 1 0 0 1 1 111 010011 Example 1: Add binary 110111 to 11100 Col 1) Add 1 + 0 = 1 Write 1 Col 2) Add 1 + 0 = 1 Write 1 Col 3) Add 1 + 1 = 2 (10 in binary) Write 0, carry 1 Col 4) Add 1+ 0 + 1 = 2 Write 0, carry 1 Col 6) Add 1 + 1 + 0 = 2 Write 0, carry 1 Col 5) Add 1 + 1 + 1 = 3 (11 in binary) Write 1, carry 1 Col 7) Bring down the carried 1 Write 1

72 Binary Addition Explanation 1 1 0 1 1 1 + 0 1 1 1 0 0 -. 1 1 111 010011 In the first two columns, there were no carries. In column 3, we add 1 + 1 = 2 Since 2 is equal to the base, subtract the base from the sum and carry 1. In column 4, we also subtract the base from the sum and carry 1. In column 6, we also subtract the base from the sum and carry 1. In column 5, we also subtract the base from the sum and carry 1. In column 7, we just bring down the carried 1 2 2223 222 What is actually happened when we carried in binary?

73 Binary Addition Verification Verification 110111 2  55 10 +011100 2 + 28 10 83 10 64 32 16 8 4 2 1 1 0 1 0 0 1 1 = 64 + 16 + 2 +1 = 83 10 1 1 0 1 1 1 + 0 1 1 1 0 0 1010011 You can always check your answer by converting the figures to decimal, doing the addition, and comparing the answers.

74 Binary Addition Example 2 Verification 111010 2  58 10 +001111 2 + 15 10 73 10 64 32 16 8 4 2 1 1 0 0 1 0 0 1 = 64 + 8 +1 = 73 10 1 1 1 0 1 0 + 0 0 1 1 1 1 1 1 11 001010 Example 2: Add 1111 to 111010. 11

75 Binary Addition  Two 1-bit values ABA + B 000 011 101 1110 “two”

76 Decimal Subtraction Example 8 0 2 5 - 4 6 5 7 Subtract 4657 from 8025: 791 1 11 8633 1)Try to subtract 5 – 7  can’t. Must borrow 10 from next column. 4) Subtract 7 – 4 = 3 3) Subtract 9 – 6 = 3 2)Try to subtract 1 – 5  can’t. Must borrow 10 from next column. But next column is 0, so must go to column after next to borrow. Add the borrowed 10 to the original 0. Now you can borrow 10 from this column. Add the borrowed 10 to the original 5. Then subtract 15 – 7 = 8. Add the borrowed 10 to the original 1.. Then subract 11 – 5 = 6

77 Decimal Subtraction Explanation  So when you cannot subtract, you borrow from the column to the left.  The amount borrowed is 1 base unit, which in decimal is 10.  The 10 is added to the original column value, so you will be able to subtract. 8633 8 0 2 5 - 4 6 5 7

78 Binary Subtraction Explanation  In binary, the base unit is 2  So when you cannot subtract, you borrow from the column to the left.  The amount borrowed is 2.  The 2 is added to the original column value, so you will be able to subtract.

79 Binary Subtraction  Two 1-bit values ABA - B 000 101 110 011 with borrow 10

80 Binary Subtraction Example 1 1 1 0 0 1 1 - 1 1 1 0 0 Example 1: Subtract binary 11100 from 110011 2 002 1 2 1101 Col 1) Subtract 1 – 0 = 1 Col 5) Try to subtract 0 – 1  can’t. Must borrow from next column. Col 4) Subtract 1 – 1 = 0 Col 3) Try to subtract 0 – 1  can’t. Must borrow 2 from next column. But next column is 0, so must go to column after next to borrow. Add the borrowed 2 to the 0 on the right. Now you can borrow from this column (leaving 1 remaining). Col 2) Subtract 1 – 0 = 1 Add the borrowed 2 to the original 0. Then subtract 2 – 1 = 1 1 Add the borrowed 2 to the remaining 0. Then subtract 2 – 1 = 1 Col 6) Remaining leading 0 can be ignored.

81 Binary Subtraction Verification Verification 110011 2  51 10 - 11100 2 - 28 10 23 10 64 32 16 8 4 2 1 1 0 1 1 1 = 16 + 4 + 2 + 1 = 23 10 1 1 0 0 1 1 - 1 1 1 0 0 2 002 1 2 11011 Subtract binary 11100 from 110011:

82 Binary Subtraction Example 2 1 0 1 0 0 1 - 1 0 1 0 0 Example 2: Subtract binary 10100 from 101001 2002 11010 Verification 101001 2  41 10 - 10100 2 - 20 10 21 10 64 32 16 8 4 2 1 1 0 1 0 1 = 16 + 4 + 1 = 21 10

83 Binary Subtraction  Borrow a “Base” when needed 001110 11110 − 0101110 = (10) 2 2 2 2 2 1 000 1 = 77 = 23 = 54

84 Multiplication (1 of 3)  Decimal (just for fun) 35 x 105 175 000 35 3675

85 Multiplication (2 of 3)  Binary, two 1-bit values AB A  B 000 010 100 111

86 Multiplication (3 of 3)  Binary, two n-bit values  As with decimal values  E.g., 1110 x 1011 1110 1110 0000 1110 10011010

87 Binary Multiplication  Bit by bit 01111 0110 00000 01111 01111 0 0000 01101110 x

88 Complements & Signed Numbers 87

89 1.5Complements  There are two types of complements for each base-r system: the radix complement and diminished radix complement.  Diminished Radix Complement - (r-1)’s Complement  Given a number N in base r having n digits, the (r–1)’s complement of N is defined as: (r n –1) – N  Example for 6-digit decimal numbers:  9’s complement is (r n – 1)–N = (10 6 –1)–N = 999999–N  9’s complement of 546700 is 999999–546700 = 453299  Example for 7-digit binary numbers:  1’s complement is (r n – 1) – N = (2 7 –1)–N = 1111111–N  1’s complement of 1011000 is 1111111–1011000 = 0100111  Observation:  Subtraction from (r n – 1) will never require a borrow  Diminished radix complement can be computed digit-by-digit  For binary: 1 – 0 = 1 and 1 – 1 = 0

90 Complements 11’s Complement (Diminished Radix Complement) AAll ‘0’s become ‘1’s AAll ‘1’s become ‘0’s Example (10110000) 2  (01001111) 2 If you add a number and its 1’s complement … 1 0 1 1 0 0 0 0 + 0 1 0 0 1 1 1 1 1 1 1 1

91 Complements  Radix Complement  Example: Base-10  Example: Base-2 The r's complement of an n-digit number N in base r is defined as r n – N for N ≠ 0 and as 0 for N = 0. Comparing with the (r  1) 's complement, we note that the r's complement is obtained by adding 1 to the (r  1) 's complement, since r n – N = [(r n  1) – N] + 1. The 10's complement of 012398 is 987602 The 10's complement of 246700 is 753300 The 2's complement of 1101100 is 0010100 The 2's complement of 0110111 is 1001001

92 Complements 22’s Complement (Radix Complement) TTake 1’s complement then add 1 TToggle all bits to the left of the first ‘1’ from the right Example: Number: 1’s Comp.: 0 1 0 1 0 0 0 0 1 0 1 1 0 0 0 0 0 1 0 0 1 1 1 1 + 1 OR 1 0 1 1 0 0 0 0 00001010

93 Complements  Subtraction with Complements  The subtraction of two n-digit unsigned numbers M – N in base r can be done as follows:

94 Complements  Example 1.5  Using 10's complement, subtract 72532 – 3250.  Example 1.6  Using 10's complement, subtract 3250 – 72532. There is no end carry. Therefore, the answer is – (10's complement of 30718) =  69282.

95 Complements  Example 1.7  Given the two binary numbers X = 1010100 and Y = 1000011, perform the subtraction (a) X – Y ; and (b) Y  X, by using 2's complement. There is no end carry. Therefore, the answer is Y – X =  (2's complement of 1101111) =  0010001.

96 1.6Signed Binary Numbers  To represent negative integers, we need a notation for negative values.  It is customary to represent the sign with a bit placed in the leftmost position of the number since binary digits.  The convention is to make the sign bit 0 for positive and 1 for negative.  Example:

97 © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed 1’s Complement The 1’s complement of a binary number is just the inverse of the digits. To form the 1’s complement, change all 0’s to 1’s and all 1’s to 0’s. For example, the 1’s complement of 11001010 is 00110101 In digital circuits, the 1’s complement is formed by using inverters: 1 1 0 0 1 0 1 0 0 0 1 1 0 1 0 1

98 © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed 2’s Complement The 2’s complement of a binary number is found by adding 1 to the LSB of the 1’s complement. Recall that the 1’s complement of 11001010 is 00110101 (1’s complement) To form the 2’s complement, add 1: +1 00110110 (2’s complement) 1 1 0 0 1 0 1 0 0 0 1 1 0 1 0 1 1 0 0 1 1 0 1 1 0

99 © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Signed Binary Numbers There are several ways to represent signed binary numbers. In all cases, the MSB in a signed number is the sign bit, that tells you if the number is positive or negative. Computers use a modified 2’s complement for signed numbers. Positive numbers are stored in true form (with a 0 for the sign bit) and negative numbers are stored in complement form (with a 1 for the sign bit). For example, the positive number 58 is written using 8-bits as 00111010 (true form). Sign bitMagnitude bits

100 © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Signed Binary Numbers Assuming that the sign bit =  128, show that 11000110 =  58 as a 2’s complement signed number: 1 1 0 0 0 1 1 0 Column weights:  128 64 32 16 8 4 2 1.  128 +64 +4 +2 =  58 Negative numbers are written as the 2’s complement of the corresponding positive number.  58 = 11000110 (complement form) Sign bitMagnitude bits An easy way to read a signed number that uses this notation is to assign the sign bit a column weight of  128 (for an 8-bit number). Then add the column weights for the 1’s. The negative number  58 is written as:

101 © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Floating Point Numbers Express the speed of light, c, in single precision floating point notation. (c = 0.2998 x 10 9 ) Floating point notation is capable of representing very large or small numbers by using a form of scientific notation. A 32-bit single precision number is illustrated. S E (8 bits) F (23 bits) Sign bitMagnitude with MSB droppedBiased exponent (+127) In scientific notation, c = 1.001 1101 1110 1001 0101 1100 0000 x 2 28. 0 10011011 001 1101 1110 1001 0101 1100 In binary, c = 0001 0001 1101 1110 1001 0101 1100 0000 2. S = 0 because the number is positive. E = 28 + 127 = 155 10 = 1001 1011 2. F is the next 23 bits after the first 1 is dropped. In floating point notation, c =

102 © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Arithmetic Operations with Signed Numbers Using the signed number notation with negative numbers in 2’s complement form simplifies addition and subtraction of signed numbers. Rules for addition: Add the two signed numbers. Discard any final carries. The result is in signed form. Examples: 00011110 = +30 00001111 = +15 00101101= +45 00001110 = +14 11101111 =  17 11111101 =  3 11111111 =  1 11111000 =  8 11110111 =  9 1 Discard carry

103 © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Arithmetic Operations with Signed Numbers 01000000 = +128 01000001 = +129 10000001 =  126 10000001 =  127 100000010= +2 Note that if the number of bits required for the answer is exceeded, overflow will occur. This occurs only if both numbers have the same sign. The overflow will be indicated by an incorrect sign bit. Two examples are: Wrong! The answer is incorrect and the sign bit has changed. Discard carry

104 © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Arithmetic Operations with Signed Numbers Rules for subtraction: 2’s complement the subtrahend and add the numbers. Discard any final carries. The result is in signed form. 00001111= +151 Discard carry 2’s complement subtrahend and add: 00011110 = +30 11110001 =  15 Repeat the examples done previously, but subtract: 00011110 00001111  00001110 11101111 11111111 11111000  00011111= +31 00001110 = +14 00010001 = +17 00000111= +71 Discard carry 11111111 =  1 00001000 =  8 (+30) –(+15) (+14) –(  17) (  1) –(  8)

105 104


Download ppt "IT101: INFORMATION TECHNOLOGY FUNDAMENTALS 1 Edited By Dr. Ahmed Abo-Bakr Information Technology Dept. Faculty of Computers & Information."

Similar presentations


Ads by Google