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

hypotl函数


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

描述:

该函数计算表达式x2+y2的值,且在计算过程中不会发生不必要的上溢或者下溢。

对于一些有限实参,该函数会发生范围错误。


参数:
long double x

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

long double y

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


返回值:

函数返回x2+y2的值。


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

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

int main(void)
{
    long double x = 3.0L, y = 4.0L;
    long double z;

    z = hypotl(x, y);
    printf("The square root of the sum of the squares of ");
    printf("%.6Lf and %.6Lf is %.6Lf.\n", x, y, z);

    return 0;
}

输出:

The square root of the sum of the squares of 3.000000 and 4.000000 is 5.000000.


相关内容:
hypot double类型的返回x2+y2的函数。
hypotf float类型的返回x2+y2的函数。
hypotd32 _Decimal32类型的返回x2+y2的函数。
hypotd64 _Decimal64类型的返回x2+y2的函数。
hypotd128 _Decimal128类型的返回x2+y2的函数。


主要参考资料:

1、ISO/IEC 9899:2024

2、ISO/IEC 9899:2018