Gets and clears the floating-point status word.
#include <float.h>
unsigned int _clear87( void );
The _clear87 function gets and clears the floating-point 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.
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 _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.
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:DOS32X
/* CLEAR87.C: 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>
void 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: 0030 - inexact, underflow
Status: 0002 - denormal