hypotd32(), hypotd64(), hypotd128() — Calculate the square root of the squares of two arguments

Standards

Standards / Extensions C or C++ Dependencies
C/C++ DFP both z/OS® V1.11

Format

#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 */

General description

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); 
Notes:
  1. These functions work in IEEE decimal floating-point format. See IEEE decimal floating-pointIEEE Decimal Floating-Point for more information.
  2. To use IEEE decimal floating-point, the hardware must have the Decimal Floating-Point Facility installed.

Returned value

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.

Example

⁄* 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);
}

Related information