1HYPOT(3)                   Linux Programmer's Manual                  HYPOT(3)
2
3
4

NAME

6       hypot, hypotf, hypotl - Euclidean distance function
7

SYNOPSIS

9       #include <math.h>
10
11       double hypot(double x, double y);
12       float hypotf(float x, float y);
13       long double hypotl(long double x, long double y);
14
15       Link with -lm.
16
17   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19       hypot():
20           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
21               || _XOPEN_SOURCE
22               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
23               || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
24
25       hypotf(), hypotl():
26           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
27               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
28               || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
29

DESCRIPTION

31       These  functions  return  sqrt(x*x+y*y).  This is the length of the hy‐
32       potenuse of a right-angled triangle with sides of length x  and  y,  or
33       the distance of the point (x,y) from the origin.
34
35       The calculation is performed without undue overflow or underflow during
36       the intermediate steps of the calculation.
37

RETURN VALUE

39       On success, these functions return the length of the  hypotenuse  of  a
40       right-angled triangle with sides of length x and y.
41
42       If x or y is an infinity, positive infinity is returned.
43
44       If x or y is a NaN, and the other argument is not an infinity, a NaN is
45       returned.
46
47       If the result overflows, a range error occurs, and the functions return
48       HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively.
49
50       If  both  arguments are subnormal, and the result is subnormal, a range
51       error occurs, and the correct result is returned.
52

ERRORS

54       See math_error(7) for information on how to determine whether an  error
55       has occurred when calling these functions.
56
57       The following errors can occur:
58
59       Range error: result overflow
60              errno  is  set  to ERANGE.  An overflow floating-point exception
61              (FE_OVERFLOW) is raised.
62
63       Range error: result underflow
64              An underflow floating-point exception (FE_UNDERFLOW) is raised.
65
66              These functions do not set errno for this case.
67

ATTRIBUTES

69       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
70       tributes(7).
71
72       ┌────────────────────────────────────────────┬───────────────┬─────────┐
73Interface                                   Attribute     Value   
74       ├────────────────────────────────────────────┼───────────────┼─────────┤
75hypot(), hypotf(), hypotl()                 │ Thread safety │ MT-Safe │
76       └────────────────────────────────────────────┴───────────────┴─────────┘
77

CONFORMING TO

79       C99, POSIX.1-2001, POSIX.1-2008.
80
81       The variant returning double also conforms to SVr4, 4.3BSD.
82

SEE ALSO

84       cabs(3), sqrt(3)
85

COLOPHON

87       This  page  is  part of release 5.13 of the Linux man-pages project.  A
88       description of the project, information about reporting bugs,  and  the
89       latest     version     of     this    page,    can    be    found    at
90       https://www.kernel.org/doc/man-pages/.
91
92
93
94                                  2021-03-22                          HYPOT(3)
Impressum