fegetenv, fesetenv_C语言中文网
| 定义于头文件 |
||
| int fegetenv( fenv_t* envp ); |
(1) | (C99 起) |
| int fesetenv( const fenv_t* envp ); |
(2) | (C99 起) |
1) 试图存储浮点环境的状态于 envp 所指向的对象。
2) 试图从 envp 所指向的对象建立浮点环境状态。对象的值必须是以先前调用 feholdexcept 或 fegetenv 获得值或是浮点宏常量。若 envp 中设置了任何浮点状态标志,则环境中标志变为被设置(然后可用 fetestexcept 测试),但不引发对应的浮点异常(执行持续而不中断)。
参数
| envp | - | 指向 fenv_t 类型对象的指针,该对象保有浮点环境的状态 |
返回值
成功时返回 0 ,否则返回非零。
示例
输出:
current exceptions raised: none current rounding method: FE_TONEAREST +11.5 -> +12.0 +12.5 -> +12.0 current exceptions raised: FE_INEXACT current rounding method: FE_TONEAREST 1.0/0.0 = inf +11.5 -> +11.0 +12.5 -> +12.0 current exceptions raised: FE_DIVBYZERO FE_INEXACT current rounding method: FE_DOWNWARD current exceptions raised: FE_INEXACT current rounding method: FE_TONEAREST
引用
- C11 standard (ISO/IEC 9899:2011):
- 7.6.4.1 The fegetenv function (p: 213)
- 7.6.4.3 The fesetenv function (p: 214)
- C99 standard (ISO/IEC 9899:1999):
- 7.6.4.1 The fegetenv function (p: 194)
- 7.6.4.3 The fesetenv function (p: 195)