This documentation is archived and is not being maintained.

_clear87, _clearfp

Get and clear the floating-point status word.

unsigned int _clear87( void );
unsigned int _clearfp( void );

Return Value

The bits in the value returned indicate the floating-point status before the call to _clear87 or _clearfp. See FLOAT.H for a complete definition of the bits returned by _clear87. Many of the math library functions modify the 8087/80287 status word, with unpredictable results. Return values from _clear87 and _status87 become more reliable as fewer floating-point operations are performed between known states of the floating-point status word.


The _clear87 function clears the exception flags in the floating-point status word, sets the busy bit to 0, and returns the status word. The floating-point status word is a combination of the 8087/80287 status word and other conditions detected by the 8087/80287 exception handler, such as floating-point stack overflow and underflow.

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


Routine Required header Compatibility
_clear87 <float.h> Win 98, Win Me, Win NT, Win 2000, Win XP
_clearfp <float.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.


// crt_clear87.c
// compile with: /Od

/* This program creates various floating-point 
 * problems, then uses _clear87 to report on these problems.
 * Compile this program with Optimizations disabled (/Od). 
 * Otherwise the optimizer will remove the code associated with 
 * the unused floating-point values.

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

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

   printf( "Status: %.4x - clear\n", _clear87()  );

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

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


Status: 0000 - clear
Status: 0003 - inexact, underflow
Status: 80000 - denormal

See Also

Floating-Point Support Routines | _control87 | _status87 | Run-Time Routines and .NET Framework Equivalents