Keil Logo Arm Logo

Technical Support

On-Line Manuals

Libraries and Floating Point Support Guide

Conventions and feedback The ARM C and C++ libraries The ARM C micro-library Floating-point support About floating-point support The software floating-point library, fplib Calling fplib routines fplib arithmetic on numbers in a particular format fplib conversions between floats, doubles, and int fplib conversion between long longs, floats, and d fplib comparisons between floats and doubles fplib C99 functions Controlling the ARM floating-point environment Floating-point functions for compatibility with Mi C99-compatible functions for controlling the ARM f C99 rounding mode and floating-point exception mac Exception flag handling Functions for handling rounding modes Functions for saving and restoring the whole float Functions for temporarily disabling exceptions ARM floating-point compiler extensions to the C99 Writing a custom exception trap handler Example of a custom exception handler Exception trap handling by signals Using C99 signalling NaNs provided by mathlib (_WA mathlib double and single-precision floating-point Nonstandard functions in mathlib IEEE 754 arithmetic Basic data types for IEEE 754 arithmetic Single precision data type for IEEE 754 arithmetic Double precision data type for IEEE 754 arithmetic Sample single precision floating-point values for Sample double precision floating-point values for IEEE 754 arithmetic and rounding Exceptions arising from IEEE 754 floating-point ar Ignoring exceptions from IEEE 754 floating-point a Trapping exceptions from IEEE 754 floating-point a Exception types recognized by the ARM floating-poi Using the Vector Floating-Point (VFP) support libr

Libraries and Floating Point Support Guide

Exception flag handling

Exception flag handling

Note

The following functionality requires you to select a floating-point model that supports exceptions, such as --fpmode=ieee_full or --fpmode=ieee_fixed.

C99 provides the following functions to clear, test and raise exceptions:

void feclearexcept(int excepts); int fetestexcept(int excepts); void feraiseexcept(int excepts);

The feclearexcept() function clears the sticky flags for the given exceptions. The fetestexcept() function returns the bitwise OR of the sticky flags for the given exceptions, so that if the Overflow flag was set but the Underflow flag was not, then calling fetestexcept(FE_OVERFLOW|FE_UNDERFLOW) would return FE_OVERFLOW.

The feraiseexcept() function raises the given exceptions, in unspecified order. If an exception trap is enabled for an exception raised this way, it is called.

C99 also provides functions to save and restore everything about a given exception. This includes the sticky flag, whether the exception is trapped, and the address of the trap handler, if any. These functions are:

void fegetexceptflag(fexcept_t *flagp, int excepts); void fesetexceptflag(const fexcept_t *flagp, int excepts);

The fegetexceptflag() function copies all the information relating to the given exceptions into the fexcept_t variable provided. The fesetexceptflag() function copies all the information relating to the given exceptions from the fexcept_t variable into the current floating-point environment.

Note

fesetexceptflag() can be used to set the sticky flag of a trapped exception to 1 without calling the trap handler, whereas feraiseexcept() calls the trap handler for any trapped exception.

Copyright © 2007-2008, 2011-2012 ARM. All rights reserved.ARM DUI 0378D
Non-ConfidentialID062912

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.