_status87, _statusfp

Get the floating point status word.

unsigned int _status87( void );

unsigned int _statusfp( void );

Routine Required Header Compatibility
_status87 <float.h> Win 95, Win NT
_statusfp <float.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

The bits in the value returned indicate the floating-point status. See the FLOAT.H include file for a complete definition of the bits returned by _status87.

Many math library functions modify the 8087/80287 status word, with unpredictable results. Return values from _clear87 and _status87 are more reliable if fewer floating-point operations are performed between known states of the floating-point status word.

Remarks

The _status87 function gets the floating-point status word. The status word is a combination of the 8087/80287/80387 status word and other conditions detected by the 8087/80287/80387 exception handler, such as floating-point stack overflow and underflow. Unmasked exceptions are checked for before returning the contents of the status word. This means that the caller is informed of pending exceptions.

_statusfp is a platform-independent, portable version of _status87. It is identical to _status87 on Intel (x86) platforms and is also supported by the MIPS platform. To ensure that your floating-point code is portable to MIPS, use _statusfp. If you are only targeting x86 platforms, use either _status87 or _statusfp.

Example

/* STATUS87.C: This program creates various floating-point errors and
 * then uses _status87 to display messages indicating these problems.
 * Compile this program with optimizations disabled (/Od). Otherwise,
 * the optimizer removes the code related to the unused floating-
 * point values.
 */

#include <stdio.h>
#include <float.h>

void main( void )
{
   double a = 1e-40, b;
   float  x, y;

   printf( "Status = %.4x - clear\n",_status87() );

   /* Assignment into y is inexact & underflows: */
   y = a;
   printf( "Status = %.4x - inexact, underflow\n", _status87() );

   /* y is denormal: */
   b = y;
   printf( "Status = %.4x - inexact underflow, denormal\n", 
           _status87() );

   /* Clear user 8087: */
   _clear87();
}

Output

Status = 0000 - clear
Status = 0003 - inexact, underflow
Status = 80003 - inexact underflow, denormal

Floating-Point Support Routines

See Also   _clear87, _control87