A specific applet we will see from time to time is one which just does arithmetic computations. Here is an example. Again, you simply click on the Compute! button to have it compute.
Of course, you can edit the entry field to do other computations. Here is how we express some basic operations.
Notice that you need to type a "
*" for multiplication and a "
^" to get a power. From the last example, we see that these applets will do computations with large integers. In fact, all applets will do arbitrary precision arithmetic with integers.
When doing division with integers, the default is typically set to truncate any values after the decimal point.
The basic computation applet gives you the option of doing floating point computations as well. To see the decimal value for this quotient, click on the place on the right side of the applet above where it says "Integers", and select "Floats" instead. Then click on the Compute! button again to see the result.
Most of the time we will simply want integer computations, but occasionally it is useful to do floating point computations as well.
It is possible to ask a Java applet to do a computation which will take it a very long time. The next example is set up to do just that. It might well take your computer years to finish the computation. Even so, click on the Compute! button, then keep reading.
The Compute! button should switch to saying Stop It!. All of the Compute! buttons do this. If the computation finishes, the button goes back to saying Compute!, but while it is computing, it switches so that you can use the same button to stop the computation. Click on the Stop It! button now to stop the computation. It may take a few moments for your computer to recover, so be patient.
Web browsers differ as to how gracefully they handle Java applets. If things start acting strangely,
Try doing a reload, and then a full reload now, whether you need it or not. It might help you to remember what to do if problems do arise later.
- First try clicking on the "Reload" button for your browser.
- If that doesn't help, do a "full reload" by clicking on the Reload button while holding down the Shift key.
- If that doesn't help, quit your web browser, and then start it up again.
Section 0.1 | Section 0.2 | Section 0.3 | Section 0.4 | Section 0.5
Chapter 0 | DNT Table of Contents
Copyright © 2001 by W. H. Freeman and Company