5.3.1. The __ieee_status function

ARM supports a second interface to the status word, similar to the __fp_status function, but the second interface sees the same status word in a different layout. This call is called __ieee_status, and it is generally the most efficient function to use for modifying the status word for VFP. (__fp_status is more efficient on FPA systems.) __ieee_status is defined in fenv.h.

Like __fp_status, __ieee_status has the prototype:

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

However, the layout of the status word as seen by __ieee_status is different from that seen by __fp_status (Figure 5.1).

Figure 5.1. IEEE status word layout

The fields in Figure 5.1 are as follows:

Table 5.5. Rounding mode control

BitsRounding mode
00Round to nearest
01Round up
10Round down
11Round toward zero

In addition to defining the __ieee_status call itself, fenv.h also defines some 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 do:


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


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);
Copyright © 1999-2001 ARM Limited. All rights reserved.ARM DUI 0067D