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

roundevenl函数


概要:
#include <math.h>
long double roundevenl(long double x);

描述:

该函数将参数x舍入为浮点形式表示的最近整数值;如果参数x位于两个整数的正中间,将向偶数方向舍入,与当前舍入方向无关。


参数:
long double x

参数为long double类型的浮点数。


返回值:

函数返回浮点形式表示的舍入得到的整数值。


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

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

int main(void)
{
    #if __STDC_VERSION_MATH_H__ >= 202311L
        printf("roundevenl(2.3L) = %.2Lf\n", roundevenl(2.3L));
        printf("roundevenl(2.7L) = %.2Lf\n", roundevenl(2.7L));
        printf("roundevenl(2.5L) = %.2Lf\n", roundevenl(2.5L));
        printf("roundevenl(3.5L) = %.2Lf\n", roundevenl(3.5L));
    #else
        puts("The implementation does not support roundevenl function.");
    #endif

    return 0;
}


可能输出:

roundevenl(2.3L) = 2.00

roundevenl(2.7L) = 3.00

roundevenl(2.5L) = 2.00

roundevenl(3.5L) = 4.00

(注:编译时实现还未支持roundevenl函数。)


相关内容:
roundeven 将double类型参数舍入为最近整数值的函数。
roundevenf 将float类型参数舍入为最近整数值的函数。
roundevend32 将_Decimal32类型参数舍入为最近整数值的函数。
roundevend64 将_Decimal64类型参数舍入为最近整数值的函数。
roundevend128 将_Decimal128类型参数舍入为最近整数值的函数。


主要参考资料:

1、ISO/IEC 9899:2024