计算实数x^2 + y^2的平方根。
C interface:
float hypotf(float x, float y);
double hypot(double x, double y);
long double hypotl(long double x, long double x);
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
y |
|
表示输入数据的浮点值。 |
输入 |
C: "km.h"
C interface:
// typical usage float x1 = 3.0, x2 = 0x1.fp127; float y1 = 4.0, y2 = -0x1p70; // special handling float e = INFINITY, f = -INFINITY, g = NAN; // print result printf("hypotf(3.0, 4.0) = %.15f\n", hypotf(x1, y1)); printf("hypotf(0x1.fp127, 0x1.fp127) = %.15f\n", hypotf(x2, x2)); printf("hypotf(-0x1p70, -0x1p70) = %.15f\n", hypotf(y2, y2)); printf("hypotf(INFINITY, 0) = %.15f\n", hypotf(e, 0.0f)); printf("hypotf(-INFINITY, 3.0) = %.15f\n", hypotf(f, x1)); printf("hypotf(NAN, 3.0) = %.15f\n", hypotf(g, x1)); printf("hypotf(NAN, INFINITY) = %.15f\n", hypotf(g, e)); /* * hypotf(3.0, 4.0) = 5.000000000000000 * hypotf(0x1.fp127, 0x1.fp127) = inf * hypotf(-0x1p70, -0x1p70) = 1669608653068460621824.000000000000000 * hypotf(INFINITY, 0) = inf * hypotf(-INFINITY, 3.0) = inf * hypotf(NAN, 3.0) = nan * hypotf(NAN, INFINITY) = inf * * */