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

fmal函数


概要:
#include <math.h>
long double fmal(long double x, long double y, long double z);

描述:

该函数计算表达式(x×y)+z的值,整个运算作为一个三元操作舍入:该函数(好像)以无限的精度计算值,并根据当前舍入模式一次舍入到返回类型。

对于某些有限参数,会发生范围错误。对于无穷大参数,会发生域错误。


参数:
long double x

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

long double y

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

long double z

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


返回值:

函数返回(x×y)+z的值,并按一次三元运算进行舍入。


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

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

int main(void)
{
    long double x = 2.0L;
    long double y = 2.5L;
    long double z = 3.0L;

    printf("fmal(%.2Lf,%.2Lf,%.2Lf) = %.2Lf\n", x, y, z, fmal(x,y,z));

    return 0;
}

输出:

fmal(2.00,2.50,3.00) = 8.00


相关内容:
fma double类型的融合乘加运算函数。
fmaf float类型的融合乘加运算函数。
fmad32 _Decimal32类型的融合乘加运算函数。
fmad64 _Decimal64类型的融合乘加运算函数。
fmad128 _Decimal128类型的融合乘加运算函数。


主要参考资料:

1、ISO/IEC 9899:2024

2、ISO/IEC 9899:2018