Presentation is loading. Please wait.

Presentation is loading. Please wait.

1.6) Storing Integer:.

Similar presentations


Presentation on theme: "1.6) Storing Integer:."— Presentation transcript:

1 1.6) Storing Integer:

2 The problem of overflow:
Overflow is the problem that occurs when a computation produces a value that falls outside the range of values that can be represented. When using two's complement notation, this might occur when adding two positive values or when adding two negative values. In either case the condition can be detected by checking the sign bit of the answer. An overflow is indicated if the addition of two positive values results in the pattern for a negative value or if the sum of two negative values appears to be positive.

3 It means 9 can't be represented in this length pattern.
continue - To know the number in the range or outside the range: Assume n= length of pattern bit Then the maximum no. = 2 n and The minimum no. = -2 n-1 For ex.: When using 2nd complement with patterns of 4 bits. The largest positive integer is = = = 8-1= +7 And the most negative integer is = = -2 3 = - 8 It means 9 can't be represented in this length pattern.

4 Excess Notation: Def.: Another method of representing integer values.
Note: the difference between an excess system and a two's complement system is that the sign bits are reversed. How to write any number in Excess notation? we need to know the length of pattern bits, also the larger and smaller integers for this length ( It means we need to know the range ). Then write all the different bit patterns of that length in the order they would appear, if we were counting in binary but you must add the excess no. to each value. If you would like to know the value in decimal from the value represented in the table of excess system you should add the value of excess to the table or if you have the value in decimal and you need to know the value in excess subtract the value of excess from the decimal number.

5 Value represented Bit pattern (4 2 1) +3 111 +2 110 +1 101 100 -1 011
Ex.: write the table of an excess notation system using bit patterns of length 3. Sol.: 1) n=3 it means excess 4 from the balance of binary system max. no. = = 4-1 = +3 min. no. = = - 4 3+4 = (7) => (111) 2 2+4 = (6) => (110) 2 1+4 = (5) => (101) 2 0+4 = (4) => (100) 2 = (3) => (011) 2 = (2) => (010) 2 = (1) => (001) 2 = (0) => (000) 2 Ex.: If we have (111) 2 in binary and we need to find which value equal this value in excess 4? (111) 2 = (7) 10 7- 4 = +3 in excess 4 Value represented Bit pattern (4 2 1) +3 111 +2 110 +1 101 100 -1 011 -2 010 -3 001 -4 000


Download ppt "1.6) Storing Integer:."

Similar presentations


Ads by Google