1hypot(3M) Mathematical Library Functions hypot(3M)
2
3
4
6 hypot, hypotf, hypotl - Euclidean distance function
7
9 c99 [ flag... ] file... -lm [ library... ]
10 #include <math.h>
11
12 double hypot(double x, double y);
13
14
15 float hypotf(float x, float y);
16
17
18 long double hypotl(long double x, long double y);
19
20
22 These functions compute the length of the square root of x^2 + y^2
23 without undue overflow or underflow.
24
26 Upon successful completion, these functions return the length of the
27 hypotenuse of a right angled triangle with sides of length x^2 and y^2.
28
29
30 If the correct value would cause overflow, a range error occurs and
31 hypot(), hypotf(), and hypotl() return the value of the macro HUGE_VAL,
32 HUGE_VALF, and HUGE_VALL, respectively.
33
34
35 If x or y is ±Inf, +Inf is returned even if one of x or y is NaN.
36
37
38 If x or y is NaN and the other is not ±Inf, a NaN is returned.
39
41 These functions will fail if:
42
43 Range Error The result overflows.
44
45 If the integer expression (math_errhandling &
46 MATH_ERREXCEPT) is non-zero, the overflow floating-point
47 exception is raised.
48
49
51 hypot(x,y), hypot(y,x), and hypot(x, −y) are equivalent.
52
53
54 hypot(x, ±0) is equivalent to fabs(x).
55
56
57 These functions takes precautions against underflow and overflow during
58 intermediate steps of the computation.
59
60
61 An application wanting to check for exceptions should call feclearex‐
62 cept(FE_ALL_EXCEPT) before calling these functions. On return, if
63 fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is
64 non-zero, an exception has been raised. An application should either
65 examine the return value or check the floating point exception flags to
66 detect exceptions.
67
69 See attributes(5) for descriptions of the following attributes:
70
71
72
73
74 ┌─────────────────────────────┬─────────────────────────────┐
75 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
76 ├─────────────────────────────┼─────────────────────────────┤
77 │Interface Stability │Standard │
78 ├─────────────────────────────┼─────────────────────────────┤
79 │MT-Level │MT-Safe │
80 └─────────────────────────────┴─────────────────────────────┘
81
83 fabs(3M), feclearexcept(3M), fetestexcept(3M), isnan(3M),
84 math.h(3HEAD), sqrt(3M), attributes(5), standards(5)
85
86
87
88SunOS 5.11 1 Sep 2002 hypot(3M)