fegetround函数
概要:
#include <fenv.h>
int fegetround(void);
描述:
该函数获取当前舍入模式。
参数:
无。
返回值:
函数返回表示当前舍入模式的宏值;如果不存在舍入模式宏或者当前舍入模式不确定,函数返回一个负值。
范例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/*函数fegetround范例*/
#include <fenv.h>
#include <stdio.h>
#pragma STDC FENV_ACCESS ON
void showRoundingDirection(void)
{
switch(fegetround())
{
case FE_DOWNWARD:
puts("FE_DOWNWARD");
break;
case FE_TOWARDZERO:
puts("FE_TOWARDZERO");
break;
case FE_UPWARD:
puts("FE_UPWARD");
break;
default:
puts("FE_TONEAREST");
break;
}
}
int main(void)
{
puts("Default rounding direction:");
showRoundingDirection();
fesetround(FE_UPWARD);
puts("Current rounding direction:");
showRoundingDirection();
return 0;
}
|
输出:
Default rounding direction:
FE_TONEAREST
Current rounding direction:
FE_UPWARD
相关内容: