Floating Point Arithmetic and Java

William Kahan has already given a great detail on the inadequacies of Java's floating point implementation. The issue of chief concern for modelling purposes is a failure to fully implement the requirements of the IEEE 754 (1985) standard for floating point arithmetic, including:

  • No ability to check for floating point exceptions on the CPU.
  • No ability to control the rounding direction of floating point operations.

Java could also increase its credentials as the language of choice for modellers by providing a built in implementation of machine interval arithmetic. As Donald Knuth argues in volume 2 of The Art of Computer Programming, p. 241:

"Interval arithmetic ... provides truly reliable error estimates. ... Since the intermediate values in a calculation often depend on each other ... the final estimates obtained with interval arithmetic will tend to be pessimistic ... However, the prospects for effective use of interval arithmetic look very good, so efforts should be made to increase its availability..."

Three Requests For Enhancement have been lodged with Sun, in the hope that some changes might be made to Java accordingly:

These RFEs are only likely to get incorporated into Java if there is enough will in the Java developer community. To see them and vote for them, you need to register as a Sun developer. You can do this from the Java website (click the "Join a Sun Developer Network Community" link in the top right hand corner). Note that you can only vote for three RFEs, so you might want to look at other ones first!