NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.1+)

IEEE Floating-Point Implementation
Java uses IEEE floating-point arithmetic. NonStop Java 2.1 uses the public-domain software-emulation package SoftFloat to
achieve IEEE floating-point compliance. The SoftFloat library is packaged with the Java Virtual Machine (JVM).
Incompatibilities between the IEEE and Compaq floating-point representations might cause loss of precision or accuracy when
you convert a Java String that represents a Compaq float or double value to a Java Float or Double value.
This subsection explains the following subjects:
Floating-point values
Double-precision values
Floating-Point Values
For floating-point values, Compaq floating-point representations have larger exponents (and therefore, a larger range) than IEEE
floating-point representations, but they are less precise, as the following table shows:
Floating-Point
Representation
Minimum Positive
Decimal Value
Maximum Decimal
Value
Compaq 1.7272337e-77F 1.1579208e77F
IEEE 1.40239846E-45F 3.40282347E+38
If you convert a Java String that represents a Compaq float value to a Java Float value, and the value is outside the IEEE
floating-point range, the effect of the conversion is indeterminate.
If you convert a Java String that represents a Compaq float value to a Java Float value, and the value is within the IEEE
floating-point range, the last bit of precision is meaningless.
Double-Precision Values
For double-precision values, Compaq floating-point representations have smaller exponents (and therefore, a smaller range) than
IEEE floating-point representations, but they are more precise, as the following table shows:
Floating-Point
Representation
Minimum Positive Decimal
Value
Maximum Decimal Value
Compaq 1.7272337110188889e-77 1.15792089237316192e77
IEEE 4.94065645841246544E-324 1.79769313486231570E+308
If you convert a Java String that represents a Compaq double value to a Java Double value, the smaller fractional part of the
IEEE double value causes loss of precision.
Controlling Floating-Point Format
You can control whether IEEE format or Compaq format is to be used for a given class. The file
TandemVMClassFP.properties is installed in /usr/tandem/java/jre/lib/ and contains a list of classes for which
explicit floating-point format control is needed. You can add your own classes and their specifications to this file. Comments at
the beginning of the file describe its format. For example:
# Tandem JVM user class native method floating point format properties file
# This file should contain a list of classes that want to explicitly specify
# what floating point format their native methods wish to use. This allows
# native methods to receive floats and doubles in something other than the
# default floating point format.