NonStop Server for Java 7.0 Programmer's Reference

In addition, a compilation unit containing JNI code that has any floating-point parameters being
passed across the JNI boundary and that is directly called by the JVM, must use the IEEE
floating-point arithmetic. IEEE floating-point format is the default for TNS/E native compilers, and
hence it is not needed to be defined in the compile command-line.
Any compilation units not called directly by the JVM can be compiled without conforming to the
IEEE floating-point format. However, the complications that can occur while using such mixed
modes are beyond the scope of this manual.
The javahjni demo shows an example of mixed modes. For information on demos, see
“Demonstration programs” (page 28).
If you want to call the C/C++ routines from 64–bit java applications, then you must compile the
routines using the following complier command-line option:
-Wlp64
Linker options
IEEE floating-point is the default format for TNS/E native compilers, and hence it is not needed to
be specified during linking.
When building 64–bit native libraries, the following additional linker option must also be used:
-set data_model lp64
How to create your own library of native code
The javahjni demonstration program shows how to create a native library for 32–bit and 64–bit
NSJ7. In order to use a native library for 32–bit JDK, it must be a 32–bit library, and for use with
64–bit JDK, it must be 64–bit library.
Directory location of javahjni (for 32–bit and 64–bit NSJ7) demo programs are listed in Table 4
(page 29).
Floating-point implementation
Java uses IEEE floating-point arithmetic for computation. This subsection explains the following
topics:
“Floating-point values” (page 39)
“Double-precision values” (page 40)
“Calling TNS floating-point functions from JNI code” (page 40)
Incompatibilities between the IEEE floating-point and TNS floating-point representations might cause
loss of precision or accuracy when you convert between TNS float or double and IEEE float
or double.
NOTE: In NSJ7, you cannot specify whether your Java classes use TNS format.
Floating-point values
For floating-point values, TNS floating-point representations have larger exponents (hence a larger
range) than IEEE floating-point representations, but they are less precise, which is demonstrated
in Table 5 (page 39):
Table 5 Floating-point ranges
Maximum decimal valueMinimum positive decimal valueFloating-point representation
1.1579208e77F1.7272337e-77FTNS
3.40282347e+38F1.40239846e-45FIEEE
Floating-point implementation 39