1 / 12

Storing Integer and Fraction with Excess Notation

This text explains the problem of overflow in storing integers and how to represent integer values using excess notation. It also discusses the storage of values with fractional parts using floating-point notation.

plester
Télécharger la présentation

Storing Integer and Fraction with Excess Notation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. continue - To know the number in the range or outside the range: • Assume n= length of pattern bit • Then the maximum no. = 2 n-1 -1 and • The minimum no. = -2 n-1 For ex.: When using 2nd complement with patterns of 4 bits. The largest positive integer is = 2 4-1 -1 = 2 3 -1 = 8-1= +7 And the most negative integer is = -2 4-1 = -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. 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. = 2 3-1 -1 = 4-1 = +3 min. no. = -2 3-1 = - 4 3+4 = (7) 10 => (111) 2 2+4 = (6) 10 => (110) 2 1+4 = (5) 10 => (101) 2 0+4 = (4) 10 => (100) 2 -1+4 = (3) 10 => (011) 2 -2+4 = (2) 10 => (010) 2 -3+4 = (1) 10 => (001) 2 -4+4 = (0) 10 => (000) 2 Ex.: If we have (111) 2 in excess notation find the value in decimal? Sol.: (111) 2 = (7) 10 7- 4 = +3 in excess 4

  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 01101011 • 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: extractthe contents of the exponent field (110), the exponent field using excess four. (110)2 = (6)10 - 4 = 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 11101011 = (- 2 3/4)10 Q: Solve: 00111100

  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 = +1 + 4 = +5 = (101)2 The result = (01011001)2 Q: Solve (– 3/8)10

More Related