------------------------- Week 04 Notes for CST8214 ------------------------- -Ian! D. Allen - idallen@idallen.ca - www.idallen.com Remember - knowing how to find out an answer is more important than memorizing the answer. Learn to fish! RTFM! (Read The Fine Manual) In Week 5 is your first midterm test: 12noon February 8. The topics on the test are in the Class Notes file: test1topics.txt You can see a copy of last year's test in last year's course notes. Lab #3 became available on January 28. Hand it in (stapled) during any lab or class before 2pm Wednesday February 6. I do not have an assignment submission box; you must hand the lab directly to me in a class. See my online timetable to know where I am during the day. Make sure your section number is clearly marked on your labs. For methods for doing the lab work, see the Class Notes files: ieee754_conversions.txt hexadecimal_conversions.txt overflow.txt binary_math.txt The Big Picture --------------- Bit patterns have no inherent meaning. They may represent signed integers, unsigned integers, floating point numbers, or even executable program instructions. The instructions that operate on the bits give the bits meaning. You write the programs that generate those instructions. Example: The 32-bit pattern 00111111100000000000000000000000 (3F800000h) If you interpret this bit pattern as: unsigned integer -> 1065353216 decimal sign/magnitude -> 1065353216 decimal two's complement -> 1065353216 decimal IEEE 754 SP FP -> 1.0 decimal Example: The 32-bit pattern 10111111100000000000000000000000 (BF800000h) If you interpret this bit pattern as: unsigned integer -> 3212836864 decimal sign/magnitude -> -1065353216 decimal two's complement -> -1082130431 decimal IEEE 754 SP FP -> -1.0 decimal Numbers represented in computers have a limited size (number of bits), hence limited precision and limited range. Numbers can be stored as integers or as floating-point values. Both precision and range are essentially the same for integers, since integers have no exponent field. Floating point numbers have both a mantissa (for precision) and an exponent field (for range); they usually trade away some precision in favour of greater range. Though floating-point numbers almost always have a greater range than integers, the range is not infinite. To store a value accurately in a floating-point representation in a computer, two things must work out: the number's value must lie within the *range* of the floating-point representation (the exponent must fit), and the value must not lose any *precision* (the mantissa must fit). In practice, some precision is often lost when working with floating-point numbers.