Chapter2Floating Point Arithmetic
The purpose of this brief chapter is to understand the basics of how a computer stores and understands numbers. The original computer designers where very wise in choosing binary representation for numbers but we will come to understand that this is not the only choice that could have been made and that this choice did not come without consequences. Consider the following problems as a cautionary, yet informative, tale. This material comes largely from chapter 5 of the Greenbau and Chartier text (remember, this web page is not your text book!)
There are three standard precisions for storing numbers in a computer.
- A single-precision number consists of 32 bits, with 1 bit for the sign, 8 for the exponent, and 23 for the significand.
- A double-precision number consists of 64 bits with 1 bit for the sign, 11 for the exponent, and 52 for the significand.
- An extended-precision number consists of 80 bits, with 1 bit for the sign, 15 for the exponent, and 64 for the significand.
Machine precision is the gap between the number 1 and the next larger floating point number. Often it is represented by \(\epsilon\). To clarify, the number 1 can always be stored in a computer system exactly and if \(\epsilon\) is machine precision for that computer then \(1+\epsilon\) is the next largest number that can be stored with that machine. For all practical purposes the computer cannot tell the difference between two numbers if the difference is smaller than machine precision. This is of the utmost important when you want to check that something is "zero" since a computer may actually store zero as machine precision. It just cannot know the difference.
As a side note: You can determine the working precision in MATLAB by typing "eps" in the command line.
The following problems are intended as homework exercises. Remember that you should be working every problem in these notes whether they are formally assigned or not. The "coding challenges" are meant to force you to code things in MATLAB and the textbook problems are pointing to the Greenbaum and Chartier text. If you are stuck on any of the coding you are encouraged to look in Chapter 2 of the text. For these two challenges you might be particularly interested in any mention of looping and conditional statements in Chapter 2 of the text.