C/C++ Programmer's Guide (G06.25+)

Using the C Run-Time Library
HP C/C++ Programmer’s Guide for NonStop Systems429301-008
4-7
IEEE Floating-Point Arithmetic
might be set to [EDOM]. Because the Tandem floating-point format does not support
NaN, the cos() function does not return NaN or optionally set errno to [EDOM]. Note
that if you specify IEEE floating-point format, NaN is supported.
The standards specify the action that must or might occur for a given condition. If the
condition cannot occur in a given implementation, the action is not required. Thus, the
HP C run-time libraries conform to the standards. Many of the reference pages for the
mathematical functions state the actions defined by the standards, even if the
conditions that require those actions cannot occur in the HP implementation. These
actions are included to enable you to write code that has the highest level of portability
to other environments.
IEEE Floating-Point Arithmetic
You have the option of choosing Tandem floating-point format or IEEE floating-point
format for performing floating-point arithmetic in native C and C++ programs. Tandem
floating-point format is the default for TNS/R systems; IEEE floating-point format is the
default for TNS/E systems.
Tandem floating-point format is compatible with pre-G06.06 C and C++ applications.
IEEE floating-point format, on the other hand, allows an application to take advantage
of the greater performance provided by the floating-point instructions available in the
processor hardware. Note that the results of IEEE floating-point operations can vary
slightly between TNS/R and TNS/E systems.
Differences Between Tandem and IEEE Floating-Point
Formats
Following are some high-level differences between the two floating-point formats:
IEEE floating-point format covers a wider range of values for the double data
type, but a narrower range of values for the float data type, than does Tandem
floating-point format (see Table 4-2 on page 4-8).
IEEE floating-point format has greater precision than Tandem floating-point
format.for the float data type, but slightly less precision for a double.
IEEE floating-point format is faster than Tandem floating-point format.
IEEE floating-point format is easier for porting applications.
IEEE floating-point default handling of overflow, underflow, divide-by-zero, and
invalid operation is better than the Tandem floating-point handling.
IEEE floating-point directed roundings and “sticky” flags are useful debugging tools
for investigating calculations that might go wrong because of rounding problems,
division by zero, or other problems. Sticky flags are exception flags that stay set
until explicitly reset by the user. They allow you to check a chain of computations.
IEEE floating-point denormalized numbers avoid computational problems that arise
from very small numbers as intermediate results in computations.