_clear87, _clearfp

获取并清除浮点状态运行。

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

返回值

按位返回的值在调用之前指示浮点状态到 _clear87 或 _clearfp。 对位的完整定义由 _clear87返回,请参见 Float.h。 许多数学库函数修改 8087/80287 状态运行,并且不可预知的结果。 返回从 _clear87 的值,并 _status87 变得更加可靠,当少浮点运算对浮点状态运行的已知状态之间。

备注

_clear87 功能清除在浮点状态的异常标志,设置忙位设置为 0,并返回状态运行。 浮点状态单词是 8087/80287 异常处理程序和其他情况中检测的组合 8087/80287 状态词,如浮点堆栈溢出和下溢。

_clearfp 是 _clear87 实例的一个独立于平台的,可移植版本。 它与 Intel (x86) 平台的 _clear87 相同的和乘以 MIPS 和 ALPHA 平台还支持。 若要确保浮点代码移植到 MIPS 或 ALPHA,请使用 _clearfp。 如果仅 x86 平台,可以使用 _clear87 或 _clearfp。

这些函数已弃用,在使用编译 /clr(公共语言运行时编译) 或 /clr:pure 时,这是因为公共语言运行时仅支持默认浮点精度。

要求

实例

必需的头

_clear87

float.h

_clearfp

float.h

有关更多兼容性信息,请参见中介绍的 兼容性

示例

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

.NET Framework 等效项

不适用。若要调用标准 C 函数,请使用 PInvoke。有关更多信息,请参见 平台调用示例

请参见

参考

浮点支持

_control87, _controlfp, __control87_2

_status87, _statusfp, _statusfp2