__ieee_status()

The ARM compiler toolchain supports an interface to the status word in the floating-point environment. This interface is provided as function __ieee_status() and it is generally the most efficient function to use for modifying the status word for VFP. __ieee_status() is defined in fenv.h.

The function prototype for __ieee_status() is:

unsigned int __ieee_status(unsigned int mask, unsigned int flags);

Note

This function requires you to select a floating-point model that supports exceptions. For example, --fpmode=ieee_full or --fpmode=ieee_fixed.

__ieee_status() modifies the writable parts of the status word according to the parameters, and returns the previous value of the whole word.

The writable bits are modified by setting them to:

new = (old & ~mask) ^ flags;

Four different operations can be performed on each bit of the status word, depending on the corresponding bits in mask and flags. See Table 4.

Table 4. Status word bit modification

Bit of maskBit of flagsEffect
00Leave alone
01Toggle
10Set to 0
11Set to 1

The layout of the status word as seen by __ieee_status() is shown in Figure 2.

Figure 2. IEEE status word layout

To view this graphic, your browser must support the SVG format. Either install a browser with native support, or install an appropriate plugin such as Adobe SVG Viewer.


The fields in Figure 2 are as follows:

In addition to defining the __ieee_status() call itself, fenv.h also defines the following constants to be used for the arguments:

#define FE_IEEE_FLUSHZERO          (0x01000000)
#define FE_IEEE_ROUND_TONEAREST    (0x00000000)
#define FE_IEEE_ROUND_UPWARD       (0x00400000)
#define FE_IEEE_ROUND_DOWNWARD     (0x00800000)
#define FE_IEEE_ROUND_TOWARDZERO   (0x00C00000)
#define FE_IEEE_ROUND_MASK         (0x00C00000)
#define FE_IEEE_MASK_INVALID       (0x00000100)
#define FE_IEEE_MASK_DIVBYZERO     (0x00000200)
#define FE_IEEE_MASK_OVERFLOW      (0x00000400)
#define FE_IEEE_MASK_UNDERFLOW     (0x00000800)
#define FE_IEEE_MASK_INEXACT       (0x00001000)
#define FE_IEEE_MASK_ALL_EXCEPT    (0x00001F00)
#define FE_IEEE_INVALID            (0x00000001)
#define FE_IEEE_DIVBYZERO          (0x00000002)
#define FE_IEEE_OVERFLOW           (0x00000004)
#define FE_IEEE_UNDERFLOW          (0x00000008)
#define FE_IEEE_INEXACT            (0x00000010)
#define FE_IEEE_ALL_EXCEPT         (0x0000001F)

For example, to set the rounding mode to round down, you would call:

__ieee_status(FE_IEEE_ROUND_MASK, FE_IEEE_ROUND_DOWNWARD);

To trap the Invalid Operation exception and untrap all other exceptions:

__ieee_status(FE_IEEE_MASK_ALL_EXCEPT, FE_IEEE_MASK_INVALID);

To untrap the Inexact Result exception:

__ieee_status(FE_IEEE_MASK_INEXACT, 0);

To clear the Underflow sticky flag:

__ieee_status(FE_IEEE_UNDERFLOW, 0);

Show/hideSee also

Tasks
Concepts

Using ARM® C and C++ Libraries and Floating-Point Support:

Reference
Copyright © 2010-2011 ARM. All rights reserved.ARM DUI 0492F
Non-ConfidentialID091611