Go to the first, previous, next, last section, table of contents.
#include <math.h> double hypot(double x, double y);
This function computes sqrt(x*x + y*y)
,
the length of a hypotenuse of a right triangle whose shorter sides are
x and y. In other words, it computes the Euclidean distance
between the points (0,0)
and (x,y)
. Since the
computation is done in extended precision, there is no danger of
overflow or underflow when squaring the arguments, whereas direct
computation of sqrt(x*x + y*y)
could
cause overflow or underflow for extreme (very large or very small)
values of x and y.
The value of sqrt(x*x + y*y)
. If both
arguments are finite, but the result is so large that it would overflow
a double
, the return value is Inf
, and errno
is set
to ERANGE
. If one of the arguments is Inf
, the return
value is Inf
and the value of errno
is left unchanged. If
one of the arguments is NaN
, the return value is NaN
and
errno
is set to EDOM
.
not ANSI, not POSIX
Go to the first, previous, next, last section, table of contents.