Name: js151677 Date: 09/01/2004
A DESCRIPTION OF THE REQUEST :
Currently Java provides no support for inspecting the IEEE 754 sticky bit exception flags to check for floating point errors in double and single precision operations. For those using Java as a simulation modelling platform (and there is a growing community particularly in agent-based modelling -- see http://repast.sourceforge.net/, http://cs.gmu.edu/~eclab/projects/mason/, http://wiki.swarm.org/), this is a serious issue.
JUSTIFICATION :
1. There is plenty of evidence that floating point errors can significantly affect the output of a simulation model. For one paper on this in the agent-based modelling community, see http://www.uni-koblenz.de/~kgt/ESSA/ESSA1/Polhill-Izquierdo-Gotts.pdf
2. Java is a very useful programming environment for scientific simulation modelling, through its platform independence. This enables scientists to share models and repeat each other's results without having to worry about portability issues. As a scientific programming environment, full support for the IEEE 754 standard should be a requirement. Java has been criticised by floating point experts for not doing this (http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf). Part of this means providing support for the IEEE 754 exception flags. Not doing so means that in the end, respectable scientists will have to move away from Java.
3. It is extremely unlikely that Java will be run on a chip that does not support IEEE 754, as this standard has been around for nearly 20 years. However, a method could be provided in the Double class returning a boolean indicating whether sticky bit support is available on this platform, or the accessor methods could throw an exception.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
There are numerous ways this could be implemented. Joe Darcy's Borneo extensions are one idea (http://www.jddarcy.org/Borneo). A simple approach to just implement exception flags could be to introduce class methods to the Float and Double classes enabling inspection and clearing of the sticky bits.
e.g.
public static boolean getImprecisionStickyBit();
public static boolean setImprecisionStickyBit(boolean value);
public static boolean anyStickyBitSet();
public static boolean clearStickyBits();
Alternatively, a floating point sticky bit class could be defined containing these methods, and accessor methods provided from Double and Float
e.g.
public static FloatingPointStickyBits getStickyBits() throws StickyBitsNotSupportedException;
public static FloatingPointStickyBits setStickyBits() throws StickyBitsNotSupportedException;
(Incident Review ID: 301596)
======================================================================
- relates to
-
JDK-5095600 Provide support for IEEE 754 directed roundings
- Closed