Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Floating-Point Guide: HP 9000 Computers > Chapter 3 Factors that Affect the Results of Floating-Point Computations

How Exceptions and Library Errors Affect Application Results

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

When an application performs a floating-point operation that causes an exception condition or a library error, and the application is not coded to detect and deal with the exception or error, the default exception-handling response of the system may introduce a dramatic amount of error into the continuing computation. The types of exception conditions and errors that can have this effect are

  • Overflow conditions

  • Underflow conditions

  • Invalid operation conditions

  • Division by zero conditions

  • Library domain and range errors (EDOM and ERANGE)

“Exception Conditions” describes the exception conditions.

Math library routines generate domain errors when they encounter invalid arguments; they generate range errors when they overflow or when they generate exact infinities from finite arguments.

Table 3-1 “Effects of Floating-Point Exceptions and Library Errors” shows the effects of these exceptions and errors on typical applications. In many cases, the effect of an exception or a library error on a program is catastrophic: that is, the program continues, but the results it produces are meaningless. A common exception to this rule is an underflow condition. An underflow means that the value returned by the operation is extremely small. In many cases—for example, if the program is evaluating a function at the point where the function crosses the X axis—a value that is very near zero is exactly what you want, so that the occurrence of an underflow is actually a successful result. In other cases an overflow may be an expected result. If, in the expression 1 + 1/f(x), f(x) overflows, then 1/f(x) is 0, and the expression evaluates to 1, which may be a perfectly acceptable result.

Table 3-1 Effects of Floating-Point Exceptions and Library Errors

Type of Error

Default System Behavior

Effect on Application

Overflow (ERANGE)

Substitute the largest normalized value or an infinity as the result

May be catastrophic unless specifically handled

Underflow

Substitute either a denormalized or zero value as the result: if the result after rounding would be smaller in magnitude than MINDOUBLE (the smallest denormalized value), substitute zero

Application usually continues successfully; however, performance may suffer

Invalid operation (invalid argument) (EDOM)

Substitute a NaN as the result

Catastrophic unless specifically handled

Division by zero

Substitute an infinity as the result

Catastrophic unless specifically handled

 

The actual nature of the inaccuracies introduced by exceptions and library errors depends on three main factors:

  • The programming environment selected (C, Fortran)

  • The default system error-response behavior, which is implementation-dependent

  • The additional error-response behavior defined by the programmer

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1997 Hewlett-Packard Development Company, L.P.