_status87, _statusfp
Go Up to float.h Index
Header File
float.h
Prototype
unsigned int _status87(void);
unsigned int _statusfp(void);
Description
Gets floating-point status.
_status87 gets the floating-point status word, which is a combination of the 80x87 status word and other conditions detected by the 80x87 exception handler.
_statusfp is identical to _status87 and is for Microsoft compatibility.
Return Value
The bits in the return value give the floating-point status. See float.h for a complete definition of the bits returned by _status87 and _status87.
Portability
POSIX | ANSI C | ANSI C++ | Win32 | Win64 | macOS | |
---|---|---|---|---|---|---|
_status87 | + | |||||
_statusfp | + |
Example
#include <float.h>
/* Prints the status of the FPU */
void print_fp_status() {
/* Obtain the FPU status word */
int fp_status = _status87();
printf("Status = %d", fp_status);
/* Write the statuses */
if (fp_status & SW_DENORMAL)
printf(" denormalized");
if (fp_status & SW_UNDERFLOW)
printf(" underflow");
if (fp_status & SW_INEXACT)
printf(" inexact");
printf("\n");
}
int _tmain(int argc, _TCHAR* argv[]) {
double big_value = 1e-40;
float short_value;
/* Print the default status */
print_fp_status();
/* Force FP status change */
short_value = big_value;
print_fp_status();
/* Clear FPU status word */
_clear87();
/* Force FP status change */
big_value = short_value;
print_fp_status();
}