Export (0) Print
Expand All
div
eof
Expand Minimize
0 out of 1 rated this helpful - Rate this topic

_clear87, _clearfp 

Gets and clears the floating-point status word.


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

The bits in the value returned indicate the floating-point status before the call to _clear87 or _clearfp. For a complete definition of the bits returned by _clear87, see Float.h. 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.

These functions are deprecated when compiling with /clr (Common Language Runtime Compilation) or /clr:pure because the common language runtime only supports the default floating-point precision.

Routine Required header Compatibility

_clear87

<float.h>

Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

_clearfp

<float.h>

Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003

For more compatibility information, see Compatibility in the Introduction.

// 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() );
}

Output

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

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.