当前位置: C语言 -- 标准库 -- <math.h> -- llroundd64

llroundd64函数


概要:
#include <math.h>
#ifdef __STDC_IEC_60559_DFP__
    long long int llroundd64(_Decimal64 x);
#endif 

描述:

该函数将参数x舍入为long long int类型的最近整数值;如果参数x位于两个整数的正中间,将向远离0的方向舍入,与当前舍入方向无关。

如果舍入得到的值超出返回类型所能表示的范围,结果是不明确的,并且可能发生域错误或者范围错误。


参数:
_Decimal64 x

参数为_Decimal64类型的浮点数。


返回值:

函数返回long long int类型的舍入得到的整数值。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
/*函数llroundd64范例*/

#include <math.h>
#include <stdio.h>

int main(void)
{
    #if __STDC_VERSION_MATH_H__ >= 202311L && defined(__STDC_IEC_60559_DFP__)
        printf("llroundd64(2.3dd) = %lld\n", llroundd64(2.3dd));
        printf("llroundd64(2.7dd) = %lld\n", llroundd64(2.7dd));
        printf("llroundd64(2.5dd) = %lld\n", llroundd64(2.5dd));
        printf("llroundd64(-2.5dd) = %lld\n", llroundd64(-2.5dd));
    #else
        puts("The implementation does not support llroundd64 function.");
    #endif

    return 0;
}


可能输出:

llroundd64(2.3dd) = 2

llroundd64(2.7dd) = 3

llroundd64(2.5dd) = 3

llroundd64(-2.5dd) = -3

(注:编译时实现还未支持十进制浮点类型。)


相关内容:
llround 将double类型参数舍入为最近整数值的函数。
llroundl 将long double类型参数舍入为最近整数值的函数。
llroundf 将float类型参数舍入为最近整数值的函数。
llroundd32 将_Decimal32类型参数舍入为最近整数值的函数。
llroundd128 将_Decimal128类型参数舍入为最近整数值的函数。


主要参考资料:

1、ISO/IEC 9899:2024