Presentation is loading. Please wait.

Presentation is loading. Please wait.

1.6) Storing Integer: 1.7) storing fraction:

Similar presentations


Presentation on theme: "1.6) Storing Integer: 1.7) storing fraction:"— Presentation transcript:

1 1.6) Storing Integer: 1.7) storing fraction:

2 1.6) 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 excess and you need to know the value in decimal 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 excess notation find the value in decimal? (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

6 1.7) storage Fraction: The storage of the value with fractional part requires that we store not only the pattern of 0s and 1s, but also the position of radix point. To do that you must based on scientific notation and is called floating-point notation

7 floating-point notation
To explain the idea we use an example of 8 bits. The high-order bit of byte as the sign bit. Take the first 3 bits that follow sign bit. Name it Exponent The last 4 bits name it Mantissa.

8 Examples: Suppose a byte consists of the floating point bit pattern Solution: Analyze the pattern Sign bit is 0 (positive) Exponent =110 Mantissa = 1011

9 Continue: First: to decode the byte, we first extract the mantissa and place the radix point on its left side (.1011) Second: extract the contents of the exponent field (110), the exponent field using excess four. (110)2 = (6) = 2

10 Continue: Third: this till us to remove the radix point in our solution to the right by two bits. [ if the result in negative it is mean to remove the radix point to the left] the result is (10.11)2 = (+ 2 3/4)10 So, the pattern = (- 2 3/4)10 Q: Solve:

11 Another example: Encode (1 1/8 )10 to binary using floating point ?
First: express in binary notation = (1.001)2 Second: we copy the pattern into the mantissa field from left to right [starting with the leftmost 1 in the binary representation] = 1001

12 Continue: Third: fill the exponent field
Fourth: the radix point after one bit from the main number so, = +1 then mantissa field = = +5 = (101)2 The result = ( )2 Q: Solve (– 3/8)10


Download ppt "1.6) Storing Integer: 1.7) storing fraction:"

Similar presentations


Ads by Google