Standards / Extensions | C or C++ | Dependencies |
---|---|---|
SAA |
both | z/OS V1R7 |
#include <math.h>
double hypot(double side1, double side2);
SAA compiler option: LANGLVL(EXTENDED), LANGLVL(SAA), or 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);
Function | SPC | Hex | IEEE |
---|---|---|---|
hypot | X | X | X |
hypotf | X | X | |
hypotl | X | X |
The hypot() family of functions returns the calculated length of the hypotenuse.
If the correct value is outside the range of representable values, ±HUGE_VAL is returned, according to the sign of the value. The value of the macro ERANGE is stored in errno, to show the calculated value is out of range. If the correct value would cause an underflow, zero is returned and the value of the macro ERANGE is stored in errno.
Special behavior for IEEE: If successful, The hypot() family of functions returns the calculated length of the hypotenuse. If the correct value overflows, hypot() sets errno to ERANGE and returns 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