Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C/C++ DFP | both | z/OS® V1.11 |
#define __STDC_WANT_DEC_FP__
#include <math.h>
_Decimal32 hypotd32(_Decimal32 x, _Decimal32 y);
_Decimal64 hypotd64(_Decimal64 x, _Decimal64 y);
_Decimal128 hypotd128(_Decimal128 x, _Decimal128 y);
_Decimal32 hypot(_Decimal32 x, _Decimal32 y); /* C++ only */
_Decimal64 hypot(_Decimal64 x, _Decimal64 y); /* C++ only */
_Decimal128 hypot(_Decimal128 x, _Decimal128 y); /* C++ only */
The hypot() family of functions calculates the length of the hypotenuse of a right-angled triangle based on the lengths of two sides x and y. A call to hypot() is equal to:
sqrt(x* x + y * y);
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_D32, HUGE_VAL_D64, or HUGE_VAL_D128 accordingly.
⁄* CELEBH03
This example illustrates the hypotd64() function.
*⁄
#define __STDC_WANT_DEC_FP__
#include <math.h>
#include <stdio.h>
void main(void)
{
_Decimal64 x, y, z;
x = 3.0DD;
y = 4.0DD;
z = hypotd64(x,y);
printf("The hypotenuse of a triangle with sides %Df and %Df"
" is %Df\n", x, y, z);
}