Chapter 1. Floating-Point Numbers Are Not Real!
When the designers of the early programming languages FORTRAN and ALGOL named one of their numeric data types REAL,
was it simply for convenience, or were they being optimistic?
Just how close is Java's float
type to the real number system of mathematics? Or, for that matter, what about the int
type and the mathematical set of integers (the whole numbers)? We know there are gremlins such as overflows and roundoff errors, but there may be more nasty stuff lurking. What other pitfalls are out there?
Roundoff Errors
Consider the common fractions , , , , , and . In the decimal, or base 10, number system, ...
Get Java™ Number Cruncher: The Java Programmer's Guide to Numerical Computing now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.