Math class is tough!
This section provides a high-level overview of the issues involved when doing lots of floating-point arithmetic.94 The discussion applies to both hardware and arbitrary-precision floating-point arithmetic.
CAUTION: The material here is purposely general. If you need to do serious computer arithmetic, you should do some research first, and not rely just on what we tell you.
|• Inexactness of computations:||Floating point math is not exact.|
|• Getting Accuracy:||Getting more accuracy takes some work.|
|• Try To Round:||Add digits and round.|
|• Setting precision:||How to set the precision.|
|• Setting the rounding mode:||How to set the rounding mode.|
There is a very nice paper on floating-point arithmetic by David Goldberg, “What Every Computer Scientist Should Know About Floating-Point Arithmetic,” ACM Computing Surveys 23, 1 (1991-03): 5-48. This is worth reading if you are interested in the details, but it does require a background in computer science.