C++官方参考链接:https://cplusplus.com/reference/cfenv/fegetexceptflag/
函数
<cfenv>
fegetexceptflag
int fegetexceptflag (fexcept_t* flagp, int excepts);
获取浮点异常标志
尝试将excepts指定的浮点异常的表示形式存储到flagp所指的fexcept_t对象中。
形参
flagp
指向存储表示的fexcept_t对象的指针。
excepts
位掩码值:实现支持的任意数量的浮点异常值的组合(带有按位或:|):
macro value(宏值) | description(描述) |
---|---|
FE_DIVBYZERO | Pole error: division by zero, or some other asymptotically infinite result (from finite arguments).(极点错误:除以零,或其他渐进无限大的结果(来自有限的实参)。) |
FE_INEXACT | Inexact: the result is not exact.(不精确:结果不精确。) |
FE_INVALID | Domain error: At least one of the arguments is a value for which the function is not defined.(定义域错误:至少有一个实参是函数没有定义的值。) |
FE_OVERFLOW | Overflow range error: The result is too large in magnitude to be represented as a value of the return type.(上溢范围错误:结果的绝对大小太大,不能用返回类型的值表示。) |
FE_UNDERFLOW | Underflow range error: The result is too small in magnitude to be represented as a value of the return type.(下溢范围错误:结果的绝对大小太小,不能用返回类型的值表示。) |
FE_ALL_EXCEPT | All exceptions (selects all of the exceptions supported by the implementation).(所有异常(选择实现支持的所有异常)。) |
某些库实现可能支持额外的浮点异常值(其对应的宏也以FE_开头)。
C99
库可以在<fenv.h>中只定义它们支持的以上宏值(其他的可能没有定义)。
C++ 11
至少上述所有宏值都在<cfenv>中定义(即使实现不支持)。
返回值
如果表示成功存储,则为0。否则为非0值。
数据竞争
同时调用此函数是安全的,不会导致数据竞争。
异常
无抛出保证:此函数从不抛出异常。