DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

hypot(S)


hypot -- Euclidean distance function

Syntax

   cc [flag ...] file ...  -lm [library ...]
   

#include <math.h>

double hypot(double x, double y);

float hypotf(float x, float y);

long double hypotl(long double x, long double y);

Description

hypot, hypotf and hypotl return
   sqrt(x * x + y * y)

taking precautions against unwarranted overflows.

Errors

When the correct value would overflow, hypot, hypotf and hypotl return a value that compares equal to +HUGE_VAL, +HUGE_VALF or +HUGE_VALL (respectively) and sets errno to ERANGE.

On systems that support IEEE NaN, if either argument is a quiet NaN, that value is returned. If either argument is a signaling NaN, a quiet NaN is returned and the invalid operation exception is raised. In either case, errno is set to EDOM. The only exception is that if one argument is a NaN and the other argument is ±INFINITY, +HUGE_VAL is returned with no error indication.

If the program was compiled with the -Xt compilation mode, a value that will compare equal to HUGE is returned instead of HUGE_VAL. These error handling procedures may be changed with the function matherr.

See also

cc(CP), math(M), matherr(S)

Standards conformance

hypot is conformant with:
X/Open Portability Guide, Issue 3, 1989 .
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003