In addition to specifying details of floating point formats and arithmetic operations, the IEEE 754 and IEEE 854 standards recommend conforming systems include several utility functions to aid in writing portable programs. For example, floating point constants associated with a format, such as the largest representable number, can be generated in a format-independent manner using the recommended functions and a handful of floating point literals. The functions perform useful tasks such as returning the floating point number adjacent to a given value and scaling a floating point number by a power of two. However, the descriptions of the functions are very brief and the two related standards give slightly different specifications for some of the functions.

This paper describes robust implementations of the IEEE recommended functions written in "100% Pure Java." These functions work under all the dynamic rounding and trapping modes supported by IEEE 754. Writing such functions in Java presents a challenge since Java does not include methods to set or query the IEEE 754 floating point state. Most previous software implementations of the IEEE recommended functions, such as analogous functions included in the C math library, are intended to be run under only the IEEE default modes, round to nearest with trapping disabled.




Download Full History