Sun Logo

Numerical Computation Guide

Suntrademark ONE Studio 8



Before You Begin

Who Should Use This Book

How This Book Is Organized

Typographic Conventions

Shell Prompts

Accessing Compiler Collection Tools and Man Pages

Accessing Compiler Collection 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 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)





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


C99 Exception Flag Functions

Locating an Exception

Using the Debuggers to Locate an Exception

Using a Signal Handler to Locate an Exception

Using 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 Exception Handling Features

Using With Fortran Programs


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



Rounding Error

Floating-point Formats

Relative Error and Ulps

Guard Digits


Exactly Rounded Operations

The IEEE Standard

Formats and Operations

Special Quantities


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




Theorem 14 and Theorem 8

Theorem 14


Differences Among IEEE 754 Implementations

Current IEEE 754 Implementations

Pitfalls in Computations on Extended-Based Systems

Programming Language Support for Extended Precision


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"


Test Programs