Sun Logo


Numerical Computation Guide

Suntrademark Studio 8

817-5073-10



Contents

Figures

Tables

Before You Begin

Who Should Use This Book

How This Book Is Organized

Typographic Conventions

Shell Prompts

Accessing Sun Studio Software and Man Pages

Accessing Compilers and Tools Documentation

Accessing Related Solaris Documentation

Resources for Developers

Contacting Sun Technical Support

Sun Welcomes Your Comments

1. Introduction

Floating-Point Environment

2. IEEE Arithmetic

IEEE Arithmetic Model

What Is IEEE Arithmetic?

IEEE Formats

Storage Formats

Single Format

Double Format

Double-Extended Format (SPARC)

Double-Extended Format (x86)

Ranges and Precisions in Decimal Representation

Base Conversion in the Solaris Environment

Underflow

Underflow Thresholds

How Does IEEE Arithmetic Treat Underflow?

Why Gradual Underflow?

Error Properties of Gradual Underflow

Two Examples of Gradual Underflow Versus Store 0

Does Underflow Matter?

3. The Math Libraries

Standard Math Library

Additional Math Libraries

Sun Math Library

Optimized Libraries

Vector Math Library (SPARC only)

libm9x Math Library

Single, Double, and Long Double Precision

IEEE Support Functions

ieee_functions(3m) and ieee_sun(3m)

ieee_values(3m)

ieee_flags(3m)

ieee_retrospective(3m)

nonstandard_arithmetic(3m)

C99 Floating Point Environment Functions

Exception Flag Functions

Rounding Control

Environment Functions

Implementation Features of libm and libsunmath

About the Algorithms

Argument Reduction for Trigonometric Functions

Data Conversion Routines

Random Number Facilities

4. Exceptions and Exception Handling

What Is an Exception?

Notes for Table 4-1

Detecting Exceptions

ieee_flags(3m)

C99 Exception Flag Functions

Locating an Exception

Using the Debuggers to Locate an Exception

Using a Signal Handler to Locate an Exception

Using libm9x.so Exception Handling Extensions to Locate an Exception

Handling Exceptions

A. Examples

IEEE Arithmetic

The Math Libraries

Random Number Generator

IEEE Recommended Functions

IEEE Special Values

ieee_flags -- Rounding Direction

C99 Floating Point Environment Functions

Exceptions and Exception Handling

ieee_flags -- Accrued Exceptions

ieee_handler -- Trapping Exceptions

ieee_handler -- Abort on Exceptions

libm9x.so Exception Handling Features

Using libm9x.so With Fortran Programs

Miscellaneous

sigfpe -- Trapping Integer Exceptions

Calling Fortran From C

Useful Debugging Commands

B. SPARC Behavior and Implementation

Floating-Point Hardware

Floating-Point Status Register and Queue

Special Cases Requiring Software Support

fpversion(1) Function -- Finding Information About the FPU

C. x86 Behavior and Implementation

D. What Every Computer Scientist Should Know About Floating-Point Arithmetic

Abstract

Introduction

Rounding Error

Floating-point Formats

Relative Error and Ulps

Guard Digits

Cancellation

Exactly Rounded Operations

The IEEE Standard

Formats and Operations

Special Quantities

NaNs

Exceptions, Flags and Trap Handlers

Systems Aspects

Instruction Sets

Languages and Compilers

Exception Handling

The Details

Rounding Error

Binary to Decimal Conversion

Errors In Summation

Summary

Acknowledgments

References

Theorem 14 and Theorem 8

Theorem 14

Proof

Differences Among IEEE 754 Implementations

Current IEEE 754 Implementations

Pitfalls in Computations on Extended-Based Systems

Programming Language Support for Extended Precision

Conclusion

E. Standards Compliance

SVID History

IEEE 754 History

SVID Future Directions

SVID Implementation

General Notes on Exceptional Cases and libm Functions

Notes on libm

LIA-1 Conformance

F. References

Chapter 2: "IEEE Arithmetic"

Chapter 3: "The Math Libraries"

Chapter 4: "Exceptions and Signal Handling"

Appendix B: "SPARC Behavior and Implementation"

Standards

Test Programs

Glossary

Index