]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
3 | .\" Permission is granted to make and distribute verbatim copies of this | |
4 | .\" manual provided the copyright notice and this permission notice are | |
5 | .\" preserved on all copies. | |
6 | .\" | |
7 | .\" Permission is granted to copy and distribute modified versions of this | |
8 | .\" manual under the conditions for verbatim copying, provided that the | |
9 | .\" entire resulting derived work is distributed under the terms of a | |
10 | .\" permission notice identical to this one. | |
c13182ef | 11 | .\" |
fea681da MK |
12 | .\" Since the Linux kernel and libraries are constantly changing, this |
13 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
14 | .\" responsibility for errors or omissions, or for damages resulting from | |
15 | .\" the use of the information contained herein. The author(s) may not | |
16 | .\" have taken the same level of care in the production of this manual, | |
17 | .\" which is licensed free of charge, as they might when working | |
18 | .\" professionally. | |
c13182ef | 19 | .\" |
fea681da MK |
20 | .\" Formatted or processed versions of this manual, if unaccompanied by |
21 | .\" the source, must acknowledge the copyright and authors of this work. | |
22 | .\" | |
23 | .\" References consulted: | |
24 | .\" Linux libc source code | |
25 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
26 | .\" 386BSD man pages | |
27 | .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu) | |
28 | .\" Modified 2002-07-27 by Walter Harms | |
29 | .\" (walter.harms@informatik.uni-oldenburg.de) | |
30 | .\" | |
a1949252 | 31 | .TH HYPOT 3 2008-08-05 "" "Linux Programmer's Manual" |
fea681da MK |
32 | .SH NAME |
33 | hypot, hypotf, hypotl \- Euclidean distance function | |
34 | .SH SYNOPSIS | |
35 | .nf | |
36 | .B #include <math.h> | |
37 | .sp | |
38 | .BI "double hypot(double " x ", double " y ); | |
d39541ec | 39 | .br |
fea681da | 40 | .BI "float hypotf(float " x ", float " y ); |
d39541ec | 41 | .br |
b9f02710 | 42 | .BI "long double hypotl(long double " x ", long double " y ); |
fea681da MK |
43 | .fi |
44 | .sp | |
20c58d70 | 45 | Link with \fI\-lm\fP. |
cc4615cc MK |
46 | .sp |
47 | .in -4n | |
48 | Feature Test Macro Requirements for glibc (see | |
49 | .BR feature_test_macros (7)): | |
50 | .in | |
51 | .sp | |
52 | .ad l | |
6bc15b8b MK |
53 | .BR hypot (): |
54 | _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE || _ISOC99_SOURCE; or | |
55 | .I cc\ -std=c99 | |
56 | .br | |
cc4615cc MK |
57 | .BR hypotf (), |
58 | .BR hypotl (): | |
6bc15b8b | 59 | _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE; or |
cc4615cc MK |
60 | .I cc\ -std=c99 |
61 | .ad b | |
fea681da MK |
62 | .SH DESCRIPTION |
63 | The | |
63aa9df0 | 64 | .BR hypot () |
fea681da MK |
65 | function returns |
66 | .RI sqrt( x * x + y * y ). | |
6bc15b8b | 67 | This is the length of the hypotenuse of a right-angled triangle |
fea681da MK |
68 | with sides of length |
69 | .I x | |
70 | and | |
71 | .IR y , | |
72 | or the distance of the point | |
73 | .RI ( x , y ) | |
74 | from the origin. | |
6bc15b8b MK |
75 | |
76 | The calculation is performed without undue overflow or underflow | |
77 | during the intermediate steps of the calculation. | |
78 | .\" e.g., hypot(DBL_MIN, DBL_MIN) does the right thing, as does, say | |
79 | .\" hypot(DBL_MAX/2.0, DBL_MAX/2.0). | |
80 | .SH RETURN VALUE | |
81 | On success, these functions return the length of a right-angled triangle | |
82 | with sides of length | |
83 | .I x | |
e49f411f | 84 | and |
6bc15b8b MK |
85 | .IR y . |
86 | ||
87 | If | |
88 | .I x | |
89 | or | |
90 | .I y | |
91 | is an infinity, | |
92 | positive infinity is returned. | |
93 | ||
94 | If | |
95 | .I x | |
96 | or | |
97 | .I y | |
98 | is a NaN, | |
99 | and the other argument is not an infinity, | |
100 | a NaN is returned. | |
101 | ||
102 | If the result overflows, | |
efe294cb | 103 | a range error occurs, |
6bc15b8b MK |
104 | and the functions return |
105 | .BR HUGE_VAL , | |
106 | .BR HUGE_VALF , | |
107 | or | |
108 | .BR HUGE_VALL , | |
109 | respectively. | |
110 | ||
111 | If both arguments are subnormal, and the result is subnormal, | |
112 | .\" Actually, could the result not be subnormal if both arguments | |
113 | .\" are subnormal? I think not -- mtk, Jul 2008 | |
efe294cb | 114 | a range error occurs, |
6bc15b8b MK |
115 | and the correct result is returned. |
116 | .SH ERRORS | |
117 | See | |
118 | .BR math_error (7) | |
119 | for information on how to determine whether an error has occurred | |
120 | when calling these functions. | |
121 | .PP | |
122 | The following errors can occur: | |
123 | .TP | |
124 | Range error: result overflow | |
125 | .I errno | |
126 | is set to | |
127 | .BR ERANGE . | |
128 | An overflow floating-point exception | |
129 | .RB ( FE_OVERFLOW ) | |
130 | is raised. | |
131 | .TP | |
132 | Range error: result underflow | |
133 | .\" .I errno | |
134 | .\" is set to | |
135 | .\" .BR ERANGE . | |
136 | An underflow floating-point exception | |
137 | .RB ( FE_UNDERFLOW ) | |
138 | is raised. | |
139 | .IP | |
140 | These functions do not set | |
141 | .IR errno | |
142 | for this case. | |
143 | .\" FIXME . Is it intentional that these functions do not set errno? | |
144 | .\" They do set errno for the overflow case. | |
145 | .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6795 | |
146 | .SH "CONFORMING TO" | |
147 | C99, POSIX.1-2001. | |
148 | The variant returning | |
149 | .I double | |
150 | also conforms to | |
151 | SVr4, 4.3BSD. | |
fea681da MK |
152 | .SH "SEE ALSO" |
153 | .BR cabs (3), | |
154 | .BR sqrt (3) |