1HYPOT(3P)                  POSIX Programmer's Manual                 HYPOT(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       hypot, hypotf, hypotl — Euclidean distance function
14

SYNOPSIS

16       #include <math.h>
17
18       double hypot(double x, double y);
19       float hypotf(float x, float y);
20       long double hypotl(long double x, long double y);
21

DESCRIPTION

23       The functionality described on this reference page is aligned with  the
24       ISO C  standard.  Any  conflict between the requirements described here
25       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2008
26       defers to the ISO C standard.
27
28       These  functions  shall  compute  the value of the square root of x2+y2
29       without undue overflow or underflow.
30
31       An application wishing to check for error situations should  set  errno
32       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
33       functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
34       FE_DIVBYZERO  |  FE_OVERFLOW  | FE_UNDERFLOW) is non-zero, an error has
35       occurred.
36

RETURN VALUE

38       Upon successful completion, these functions shall return the length  of
39       the hypotenuse of a right-angled triangle with sides of length x and y.
40
41       If  the  correct  value would cause overflow, a range error shall occur
42       and hypot(), hypotf(), and hypotl() shall return the value of the macro
43       HUGE_VAL, HUGE_VALF, and HUGE_VALL, respectively.
44
45       If  x  or  y  is ±Inf, +Inf shall be returned (even if one of x or y is
46       NaN).
47
48       If x or y is NaN, and the other is not ±Inf, a NaN shall be returned.
49
50       If both arguments are subnormal and the correct result is subnormal,  a
51       range error may occur and the correct result shall be returned.
52

ERRORS

54       These functions shall fail if:
55
56       Range Error The result overflows.
57
58                   If  the  integer expression (math_errhandling & MATH_ERRNO)
59                   is non-zero, then errno shall be set to [ERANGE].   If  the
60                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
61                   non-zero, then the overflow floating-point exception  shall
62                   be raised.
63
64       These functions may fail if:
65
66       Range Error The result underflows.
67
68                   If  the  integer expression (math_errhandling & MATH_ERRNO)
69                   is non-zero, then errno shall be set to [ERANGE].   If  the
70                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
71                   non-zero, then the underflow floating-point exception shall
72                   be raised.
73
74       The following sections are informative.
75

EXAMPLES

77       See the EXAMPLES section in atan2().
78

APPLICATION USAGE

80       hypot(x,y), hypot(y,x), and hypot(x, −y) are equivalent.
81
82       hypot(x, ±0) is equivalent to fabs(x).
83
84       Underflow  only  happens when both x and y are subnormal and the (inex‐
85       act) result is also subnormal.
86
87       These functions take precautions against overflow  during  intermediate
88       steps of the computation.
89
90       On   error,   the   expressions  (math_errhandling  &  MATH_ERRNO)  and
91       (math_errhandling & MATH_ERREXCEPT) are independent of each other,  but
92       at least one of them must be non-zero.
93

RATIONALE

95       None.
96

FUTURE DIRECTIONS

98       None.
99

SEE ALSO

101       atan2(), feclearexcept(), fetestexcept(), isnan(), sqrt()
102
103       The Base Definitions volume of POSIX.1‐2008, Section 4.19, Treatment of
104       Error Conditions for Mathematical Functions, <math.h>
105
107       Portions of this text are reprinted and reproduced in  electronic  form
108       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
109       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
110       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
111       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
112       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
113       event of any discrepancy between this version and the original IEEE and
114       The  Open Group Standard, the original IEEE and The Open Group Standard
115       is the referee document. The original Standard can be  obtained  online
116       at http://www.unix.org/online.html .
117
118       Any  typographical  or  formatting  errors that appear in this page are
119       most likely to have been introduced during the conversion of the source
120       files  to  man page format. To report such errors, see https://www.ker
121       nel.org/doc/man-pages/reporting_bugs.html .
122
123
124
125IEEE/The Open Group                  2013                            HYPOT(3P)
Impressum