C99 | double hypot (double x , double y);
float hypotf (float x , float y); long double hypotl (long double x, long double y); |
C++11 | double hypot (double x , double y);
float hypot (float x , float y); long double hypot (long double x , long double y); double hypot (Type1 x , Type2 y); // additional overloads |
C99 | 头文件<tgmath.h> 提供了该函数的泛型类型宏版本。 |
C++11 | 这个头文件(<cmath>) 为其他算术类型(Type1和Type2)的组合提供了额外的重载: 这些重载在计算前将其实参转换为double,除非至少有一个实参是long double类型 (在这种情况下,两个实参都被转换为long double类型)。 |
/* hypot example */ #include <tdio.h> /* printf */ #include <math.h> /* hypot */ int main () { double leg_x, leg_y, result; leg_x = 3; leg_y = 4; result = hypot (leg_x, leg_y); printf ("%f, %f and %f form a right-angled triangle.\n",leg_x,leg_y,result); return 0; } |
sqrt | 计算平方根(function ) |
pow | 幂(function ) |