1hypot(3)                   Library Functions Manual                   hypot(3)
2
3
4

NAME

6       hypot, hypotf, hypotl - Euclidean distance function
7

LIBRARY

9       Math library (libm, -lm)
10

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

ATTRIBUTES

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

STANDARDS

80       C11, POSIX.1-2008.
81

HISTORY

83       C99, POSIX.1-2001.
84
85       The variant returning double also conforms to SVr4, 4.3BSD.
86

SEE ALSO

88       cabs(3), sqrt(3)
89
90
91
92Linux man-pages 6.05              2023-07-20                          hypot(3)
Impressum