This applet explores the way that floating point numbers are represented in Maple, as discussed in Chapter 2 of Introduction to Scientific Programming.

The formula for Maple's floating point number representation is

	m x 10^e
where m is between [1...10) and e is between minexp and maxexp. m is the mantissa size (the number of digits in the mantissa). 1 is always included in the mantissa, and 10 never is. minexp is the minimum exponent and maxexp is the maximum exponent.

First you'll want to bring up the applet by clicking on the button below.

If you see this, then Java is not running in your browser!
An applet would normally go here...


You can see that we have a mantissa size of 1, a minexp of -1 and a maxexp of 1. These values are listed in the fields at the top of the applet. At the bottom of the applet is a graph which shows all the possible foating point numbers which can be made using the given mantissa size and the exponent.


There are two lists above the graph. In the first one are all the posible mantissas. In our case, with a mantissa size of 1, the numbers go from

	1 through 9
The second list has all the possible floating point numbers we can make given the constraints of mantissa size and exponent range. Right now we can represent
	.1 to .9 by tenths, 
	1 to 9 by ones, and
	10 to 90 by tens.

When you add 2 of the numbers, sometimes you can get an exact answer and sometimes not. 1 and 2 are in the list (and on the graph) of numbers we can represent , and if you add them

	1 + 2 = 3
3 is also in the floating point list, so it could be represented exactly. You can check this by putting into the equation input field
	1 + 2
or by cliking on the button below, which will put '1 + 2' into the equation field for you.


But, what if we try to add 1 and 10.

	1 + 10 = 11
11 cannot be represented under our current Maple number system, so we would choose the closest number which we can represent which is 10. This is not very accurate
	11 -> 10

This is because as we get further away from 0 the numbers which we can represent get further apart (you can see this on the graph). This is because the number of significant digits stays the same while the number gets larger (exponent gets bigger). If we really wanted to do the above addition of 1 and 10 and get an exact result, we would need to increase the number of significant digits to 2. So, we would increase the mantissa size to 2.


You can see that 11 is now on the FP list and on the graph. Try comming up with other examples yourself, and change the mantissa size, minimum exponent and maximum exponent until you can represent the result. For example 2 + 20, .2 + .3.


If you ever want to get back to the way the applet originally came up (Mantissa Size 1, Minimum Exponent -1, Maximum Exponent 1), then press this button. Try it.



Next, lets try some multiplication. What if we try multiplying 10 and 60?
	10 * 60 = 600 
But, 600 isn't on our list. In fact, the closest we can get is 90. (To be sure that 600 isn't on the graph, you can click on the button to the right of the graph(>). This will increase the maximum number the graph shows by 10. In our case, the graph will then show 900, and you can see that 600 does not have a mark above it. To get back to our original view, you can click on the button to the left of the graph(<) or choose reset from the File menu).
	600 -> 90
90 is a long way from 600. What if we really want 600? We need to figure out a way to get 600 into our number system. Increasing the mantissa size won't work, since this will only let us represent our current range of numbers more accurately. Intuitively, increasing our maximum exponent sould help since 10^2 will be larger than 10^1. Click on this button to increase the maximum exponent to 2, or try increasing it yourself by clicking on the button to the right of Max Exponent (>).

As you can see, 60 and 10 are still on our list and now so is 600.


Now lets suppose we want to do some division in our number system. Make sure that your current setting are Mantissa 1, Min Exponent -1, and Max Exponent 2, or click on the previous button. If we want to divide 400 by 2 (both of which are in our number system - on the list of floating point numbers).

	400 / 2 = 200
which we can see is in the list and on the graph. What about
	400 / 20 = 20?
This is obviously on the floating point list, and if we decrease the magnitude of the maximum on the graph (< button to the left of the graph) we can easily see that 20 is on the graph. (To zoom in on a portion of the graph you can also drag the mouse within the graph to delineate a section of the graph. You will see a rectangle around the area you've chosen and when you let up on the mouse button the graph will zoom in on that rectangle.

Lets try dividing something smaller, like 2 divided by 100.

	2 / 100 = .02
You can see from the floating point list that .02 is not a number which we can represent in our number system. In fact, if you zoom in on the graph several times you will see that there is no number in our system between 0 and .1. (We can get closer to 1, but when using floating point numbers there will always be some very small number which you cannot represent.) If you are having trouble zooming in to the correct region where you can see that .02 is not represented on our graph, click on this button



Intuition will tell you that to get a smaller number we need a smaller exponent. So, we decrement the minexp (you can do this yourself or click on the button below).


You can see from the floating point list that .02 is now in our number system. If you zoom in on the graph you can see that .02 has a line above it. Now try to find a number system from which you can do 10/20, 1/200, .04/80.





This is not integrated in yet


You can see that you can represent number up to 90,000, rather than just up to 90 like you could before. But, because there is only one digit in the mantissa, you can only represent any number with one significant digit. When the numbers are small, like .1, you can represent them to the nearest 10th, but by the time you get to 90,000 you can only represent them to the nearest 10,000th.



Using the input fields, you can change the mantissa size and the minimum and maximum exponent values. When you push the 'recalculate' button, the possible mantissas and floats are recalculated, and the floats are plotted. When you recalculate, the plot is automatically reset so that it holds all the possible floating point numbers.