0 index
1 Internal Representation - 2
2 Why binary?
3 Limitations
4 Floating point number representation
5 Floating point number representation 2
6 diagram
7 Example 1
8 Example 2
9 Binary representation of decimal numbers
10 Example 3.1
11 Example 3.2
12 Binary representation of decimal numbers 2
13 Example 4.1
14 Example 4.2
15 Example 5.1
16 Example 5.2
17 Binary representation of decimal numbers 3
18 Example 6.1
19 Example 6.2
20 Example 6.3
21 Example 6.4
22 Example 6.5
23 Example 7.1
24 Example 7.2
25 Example 7.3
26 Example 7.4
27 Example 7.5
28 Example 8.1
29 Example 8.2
30 Example 9.1
31 Example 9.2

outline
created using slideshow.cgi by Andy Harris















CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
1. Internal Representation - 2
  • real numbers
    • represented using scientific notation
    • 24378 = 2.378 x 104
      • except it's base 2
    • components are sign, mantissa, and exponent



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
2. Why binary?
  • Electronic bistable environment
    • on/off, high/low voltage
  • Reliability
    • with only 2 values, can be widely separated
    • therefore clearly differentiated
    • "drift" causes less error



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
3. Limitations
  • Fixed numbers of bits for a number
    • size depends on computer design
  • Limits on size of integers
    • e.g., -32768 to +32767 (16 bit word)
  • Limit on size of decimal numbers (exponent)
  • Limit on accuracy of decimal numbers (mantissa)



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
4. Floating point number representation
  • If x is any real number, its normal form representation is,
           x = f * 10E
  • Ex:
               125.32   =    0.12532 * 103
    -125.32 = -0.12532 * 103
    0.65 = 0.65 * 100



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
5. Floating point number representation 2
  • The number f of the representation is called the mantissa and the E is the exponent.



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
6. diagram
  • sign
    of
    mantissa
    sign
    of
    exponent
    d1d2d3d4d5d6d7d8
    digits
    of
    mantissa
    digits
    of
    exponent



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
7. Example 1
  • Ex: Let x = 125.32. Then the representation is, x = 0.12532 * 103
  • 01253003



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
8. Example 2
  • Ex: Let x = -0.0325475. Then the representation is, x = -0.3255 * 10-1
  • 13255101



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
9. Binary representation of decimal numbers
  • Recall, the general binary representation of a positive integer is,
    dn2n + dn - 12n - 1 + ... + d121 + d020



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
10. Example 3.1
  • Ex: Convert decimal 43 to binary.
    43/2 = 21 + 1   5/2 = 2 + 1
    21/2 = 10 + 1 2/2 = 1 + 0
    10/2 = 5 + 0 1/2 = 0 + 1



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
11. Example 3.2
  • i.e. continue division by 2, noting all remainders, until a quotient of zero is reached. The resulting bit sequence, reads backwards,
    101011 = 43.    (32 + 8 + 2 + 1 = 43)



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
12. Binary representation of decimal numbers 2
  • the general binary representation of a positive number less than 1 is,
    d-12-1 + d-22-2 + d-32-3...



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
13. Example 4.1
  • Ex: Convert .625 into binary.
    .625 x 2 = 1.250 (extract the 1)
    .250 x 2 = 0.500 (extract the 0)
    .500 x 2 = 1.000 (extract the 1)



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
14. Example 4.2
  • The digits extracted are taken in the order extracted. In this case, the result is .101 (1/2 + 1/8 = 5/8 = .625)



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
15. Example 5.1
  • Ex: Convert 1/3 into binary.



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
16. Example 5.2
  • Ans: .010101010...



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
17. Binary representation of decimal numbers 3
  • One source of error in computations is due to back and forth conversion between decimal and binary.



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
18. Example 6.1
  • Ex: Find the sum of .6 + .6?



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
19. Example 6.2
  • 1. Convert .6 to binary:
    Ans:      .1001100110011...



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
20. Example 6.3
  • 2. Find sum:
    Ans:     .10011001
    .10011001
    1.00110010



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
21. Example 6.4
  • 3. Convert answer back to decimal:
    1 + 1/8 + 1/16 + 1/128 = 1.195 (actual sum = 1.2)



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
22. Example 6.5
  • Error = 1.2 - 1.195 = .005 due to roundoff made during conversions.



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
23. Example 7.1
  • Ex: Find a 16 bit representation of the approximation 1.414 to the square root of 2.



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
24. Example 7.2
  • a) Convert left side of the decimal point.
  • Ans: 1



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
25. Example 7.3
  • b) Convert right side of the decimal point. Using multiplicative method we get,
    0.828 1.656 1.312 0.624 1.248 0.496
    0.992 1.984 1.968 1.936 1.872 1.744
    1.488 0.976 1.952



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
26. Example 7.4
  • c) required 16 bit approximation is,
              1.0110 1001 1111 101



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
27. Example 7.5
  • d) convert this back to decimal and find the roundoff error.



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
28. Example 8.1
  • Ex: Express the 16 bit approximation
    11.0010 0100 0011 11 to pi in normalized form.



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
29. Example 8.2
  • Ans: the normalized form is,
              .1100 1001 0000 1111 x 22
  • In normalized form the leading 1 appears next to the decimal point.



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
30. Example 9.1
  • Ex: Interpret the string 0110 1110 0000 0100 using the following convention:
    • the leading bit (most significant bit, MSB) is the sign of mantissa (sm).
    • next 11 bits corresponds to mantissa (m).
    • next bit tells the sign of the exponent (se).
    • next three bits corresponds to exponent (e).



































CSCI N301 Fundamental CS Concepts: n301/Numbering Systems
31. Example 9.2
  • Ans: the parts are:
              sm = 0; m = 11011100000; se = 0; e = 100
  • Shifting the decimal point four places to the right (?) gives,
    1101.11, which is equal to 13.75



































outline

Internal Representation - 2

Why binary?

Limitations

Floating point number representation

Floating point number representation 2

diagram

Example 1

Example 2

Binary representation of decimal numbers

Example 3.1

Example 3.2

Binary representation of decimal numbers 2

Example 4.1

Example 4.2

Example 5.1

Example 5.2

Binary representation of decimal numbers 3

Example 6.1

Example 6.2

Example 6.3

Example 6.4

Example 6.5

Example 7.1

Example 7.2

Example 7.3

Example 7.4

Example 7.5

Example 8.1

Example 8.2

Example 9.1

Example 9.2