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

hypotf函数


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

描述:

该函数计算表达式x2+y2的值,在计算的中间阶段没有过度的溢出或者下溢。

该函数可能会发生范围错误(range error)


参数:
float x

参数为一个float类型的浮点数。

float y

参数为一个float类型的浮点数。


返回值:

函数返回x2+y2的值。


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

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

int main(void)
{
    float x = 3.0f, y = 4.0f;
    float z;

    z = hypotf(x, y);
    printf("The square root of the sum of the squares of %.6f and %.6f is %.6f.\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的函数。
hypotl long double类型的返回x2+y2的函数。