標準/拡張機能 | C/C++ | 依存項目 |
---|---|---|
SAA |
両方 | z/OS V1R7 |
#include <math.h>
double hypot(double side1, double side2);
SAA コンパイラー・オプション: LANGLVL(EXTENDED), LANGLVL(SAA)、 または LANGLVL(SAAL2)
#define _XOPEN_SOURCE
#include <math.h>
double hypot(double side1, double side2);
#define _ISOC99_SOURCE
#include <math.h>
float hypotf(float side1, float side2);
long double hypotl(long double side1, long double side2);
#define _TR1_C99
#include <math.h>
float hypot(float side1, float side2);
long double hypot(long double side1, long double side2);
sqrt(side1* side1 + side2 * side2);
関数 | SPC | Hex | IEEE |
---|---|---|---|
hypot | X | X | X |
hypotf | X | X | |
hypotl | X | X |
hypot() ファミリーの関数は、計算された斜辺の長さを戻します。
正しい値が表示可能な値の範囲外である場合は、±HUGE_VAL が、値の符号に応じて戻されます。マクロ ERANGE の値が errno に保管され、計算値が範囲外であることを示します。正しい値がアンダーフローを起こした場合は、0 が戻され、マクロ ERANGE の値が errno に保管されます。
IEEE の特殊な動作: 正常に実行された場合、hypot() ファミリーの関数は、計算された斜辺の長さを戻します。 正しい値がオーバーフローすると、hypot() は errno に ERANGE を設定し、HUGE_VAL を戻します。
⁄* CELEBH01
This example calculates the hypotenuse of a right-angled
triangle with sides of 3.0 and 4.0.
*⁄
#include <math.h>
#include <stdio.h>
int main(void)
{
double x, y, z;
x = 3.0;
y = 4.0;
z = hypot(x,y);
printf("The hypotenuse of the triangle with sides %lf and %lf"
" is %lf¥n", x, y, z);
}
The hypotenuse of the triangle with sides 3.000000 and 4.000000 is 5.000000