### Joseph D. Darcy

###
EECS Department

University of California, Berkeley

Technical Report No. UCB/CSD-98-1009

1998

### http://www2.eecs.berkeley.edu/Pubs/TechRpts/1998/CSD-98-1009.pdf

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.

BibTeX citation:

@techreport{Darcy:CSD-98-1009, Author = {Darcy, Joseph D.}, Title = {Writing robust IEEE recommended functions in "100% Pure Java"(TM)}, Institution = {EECS Department, University of California, Berkeley}, Year = {1998}, URL = {http://www2.eecs.berkeley.edu/Pubs/TechRpts/1998/5790.html}, Number = {UCB/CSD-98-1009}, Abstract = {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. <p>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.} }

EndNote citation:

%0 Report %A Darcy, Joseph D. %T Writing robust IEEE recommended functions in "100% Pure Java"(TM) %I EECS Department, University of California, Berkeley %D 1998 %@ UCB/CSD-98-1009 %U http://www2.eecs.berkeley.edu/Pubs/TechRpts/1998/5790.html %F Darcy:CSD-98-1009