Floating point environment
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
浮点环境的浮点状态标志的设置和控制方式实现支持。它是本地线程,每个线程都会继承父线程的初始状态,其浮点环境。浮点运算修改浮点状态标志,用于指示异常结果或辅助信息。浮点控制模式的状态会影响一些浮点运算的结果.
原文:
The floating-point environment is the set of floating-point status flags and control modes supported by the implementation. It is thread-local, each thread inherits the initial state of its floating-point environment from the parent thread. Floating-point operations modify the floating-point status flags to indicate abnormal results or auxiliary information. The state of floating-point control modes affects the outcomes of some floating-point operations.
浮点环境访问和修改是唯一有意义的
#pragma STDC FENV_ACCESS设置为
ON
。否则,执行是免费的假设,浮点控制模式始终是默认的,浮点状态标志从来没有测试或修改。在实践中,一些现有的编译器支持#pragma
明确,但大多数编译器允许反正有意义的访问浮点环境.原文:
The floating-point environment access and modification is only meaningful when
#pragma STDC FENV_ACCESS is set to
ON
. Otherwise the implementation is free to assume that floating-point control modes are always the default ones and that floating-point status flags are never tested or modified. In practice, few current compilers support the #pragma
explicitly, but most compilers allow meaningful access to the floating-point environment anyway.[编辑] 类型
在头文件
<fenv.h> 中定义 | |
fenv_t | 类型代表整个浮点环境
原文: The type representing the entire floating-point environment |
fexcept_t | 该型集体所有的浮点状态标志
原文: The type representing all floating-point status flags collectively |
[编辑] 功能
(C99) |
清除指定的浮点状态标志 原文: clears the specified floating-point status flags (函数) |
(C99) |
确定哪些指定浮点状态标志被设置 原文: determines which of the specified floating-point status flags are set (函数) |
(C99) |
提出了指定的浮点异常 原文: raises the specified floating-point exceptions (函数) |
(C99) (C99) |
复制或浮点环境指定的浮点状态标志的状态 原文: copies the state of the specified floating-point status flags from or to the floating-point environment (函数) |
(C99) (C99) |
获取或设置舍入的方向 (函数) |
(C99) |
保存或恢复当前浮点环境 原文: saves or restores the current floating point environment (函数) |
(C99) |
保存环境,清除所有状态标志,而忽略了未来所有的错误 原文: saves the environment, clears all status flags and ignores all future errors (函数) |
(C99) |
浮点环境恢复和提高了先前抛出异常 原文: restores the floating-point environment and raises the previously raise exceptions (函数) |
[编辑] 宏
浮点异常 (常量宏) | |
浮点舍入方向 (常量宏) | |
(C99) |
默认的浮点环境 (常量宏) |
本章尚未完成 原因:FENV_ACCESS |