Important: The information in this document is obsolete and should not be used for new development.
hypot
You can use thehypot
function to compute the length of the hypotenuse of a right triangle.
double_t hypot(double_t x, double_t y);
- x
- Any floating-point number.
y
- Any floating-point number.
DESCRIPTION
Thehypot
function computes the square root of the sum of the squares of its arguments. This is an ANSI standard C library function.
The function
hypot
performs its computation without undeserved overflow or underflow. For example, if is greater than the maximum representable value
of the data type but the square root of is not, then no overflow occurs.EXCEPTIONS
When x and y are finite and nonzero, either the result of is exact or it raises one of the following exceptions:
- inexact (if the result must be rounded or an overflow or underflow occurs)
- overflow (if the result is outside the range of the data type)
- underflow (if the result is inexact and must be represented as a denormalized number or 0)
SPECIAL CASES
Table 10-40 shows the results when one of the arguments to thehypot
function is a zero, a NaN, or an Infinity. In this table, x and y are finite, nonzero floating-point numbers.
Special cases for the hypot
functionOperation Result Exceptions raised |y| None |x| None |y| None |x| None NaN None[65] NaN None[65] None None + None + None + None + None EXAMPLES
z = hypot(2.0, 2.0); /* z = sqrt(8.0) 2.82843. The inexact exception is raised. */
[65] If the NaN is a signaling NaN, the invalid exception is raised.