_status87, _statusfp, _statusfp2
Gets the floating-point status word.
unsigned int _status87( void );
unsigned int _statusfp( void );
void _statusfp2(unsigned int *px86, unsigned int *pSSE2)
Parameters
px86
This address is filled with the status word for the x87 floating-point unit.pSSE2
This address is filled with the status word for the SSE2 floating-point unit.
Return Value
For _status87 and _statusfp, the bits in the value that's returned indicate the floating-point status. See the FLOAT.H include file for a definition of the bits that are returned by _statusfp. Many math library functions modify the floating-point status word, with unpredictable results. Return values from _clearfp and _statusfp are more reliable if fewer floating-point operations are performed between known states of the floating-point status word. _statusfp2 has no return value.
Remarks
The _statusfp function gets the floating-point status word. The status word is a combination of the floating-point processor status and other conditions detected by the floating-point exception handler—for example, floating-point stack overflow and underflow. Unmasked exceptions are checked for before the contents of the status word are returned. This means that the caller is informed of pending exceptions. On x86 platforms, _statusfp returns a combination of the x87 and SSE2 floating-point status. On x64 platforms, the status that's returned is based on the SSE’s MXCSR status. On ARM platforms, _statusfp returns status from the FPSCR register.
_statusfp is a platform-independent, portable version of _status87. It is identical to _status87 on Intel (x86) platforms and is also supported by the x64 and ARM platforms. To ensure that your floating-point code is portable to all architectures, use _statusfp. If you are only targeting x86 platforms, you can use either _status87 or _statusfp.
We recommend _statusfp2 for chips (such as the Pentium IV) that have both an x87 and an SSE2 floating-point processor. For _statusfp2, the addresses are filled by using the floating-point status word for both the x87 or the SSE2 floating-point processor. For a chip that supports x87 and SSE2 floating-point processors, EM_AMBIGUOUS is set to 1 if _statusfp or _controlfp is used and the action was ambiguous because it could refer to the x87 or the SSE2 floating-point status word. The _statusfp2 function is only supported on x86 platforms.
These functions are deprecated for /clr (Common Language Runtime Compilation) or /clr:pure compilation because the common language runtime (CLR) only supports the default floating-point precision.
Requirements
Routine |
Required header |
---|---|
_status87, _statusfp, _statusfp2 |
<float.h> |
For additional compatibility information, see Compatibility.
Example
// crt_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>
int 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();
}
Status = 0000 - clear Status = 0003 - inexact, underflow Status = 80003 - inexact underflow, denormal
.NET Framework Equivalent
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.