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

fmaximum_mag函数


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

描述:

该函数确定较大绝对值的参数的值。

如果|x|>|y|,函数返回参数x的值;如果|y|>|x|,函数返回参数y的值;否则返回fmaximum(x,  y)。

如果存在非数值参数,该函数返回非数值,且不会引发浮点异常。

fmaximum_mag函数和fmaximum_mag_num函数类似,唯一的区别在于非数值参数的处理:如果存在一个非数值参数,fmaximum_mag函数返回非数值;fmaximum_mag_num函数返回数值。


参数:
double x

参数为double类型的浮点数。

double y

参数为double类型的浮点数。


返回值:

函数返回较大绝对值的参数的值。


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

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

int main(void)
{
    #if __STDC_VERSION_MATH_H__ >= 202311L
        printf("fmaximum_mag(8.0, 2.0) = %.2f\n", fmaximum_mag(8.0, 2.0));
        printf("fmaximum_mag(-8.0, -2.0) = %.2f\n", fmaximum_mag(-8.0, -2.0));
    #else
        puts("The implementation does not support fmaximum_mag function.");
    #endif

    return 0;
}

输出:

The implementation does not support fmaximum_mag function.


相关内容:
fmaximum_magf float类型的确定较大绝对值的参数的函数。
fmaximum_magl long double类型的确定较大绝对值的参数的函数。
fmaximum_magd32 _Decimal32类型的确定较大绝对值的参数的函数。
fmaximum_magd64 _Decimal64类型的确定较大绝对值的参数的函数。
fmaximum_magd128 _Decimal128类型的确定较大绝对值的参数的函数。


主要参考资料:

1、ISO/IEC 9899:2024