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 6 Floating-Point Trap Handling

Detecting Exceptions without Enabling Traps

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

If you do not enable traps for floating-point exceptions, you can still determine whether the exceptions have occurred. When an exception occurs and the corresponding exception trap enable bit is not set, the system sets the corresponding exception flag. The exception flags are cumulative; once a flag is set, it remains set for the duration of the program unless you clear it. (This is why the exception flags are also called sticky bits.)

At critical points in your program, you can call the fetestexcept function (described in “Manipulating the Exception Flags: fegetexceptflag, fesetexceptflag, fetestexcept, feraiseexcept, feclearexcept”) to determine whether an exception has occurred. You can then respond to the exception as you wish. The program example in that section illustrates the use of this function.

NOTE: Be careful if you use these functions at higher optimization levels (2 and above). See “Run-Time Mode Control: The fenv(5) Suite”.
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1997 Hewlett-Packard Development Company, L.P.