OSDN Git Service

(split) LDP man-pages の original/ を v3.29 に更新。
[linuxjm/LDP_man-pages.git] / original / man3 / hypot.3
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.
11 .\"
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.
19 .\"
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 .\"
31 .TH HYPOT 3 2010-09-20 ""  "Linux Programmer's Manual"
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 );
39 .br
40 .BI "float hypotf(float " x ", float " y );
41 .br
42 .BI "long double hypotl(long double " x ", long double " y );
43 .fi
44 .sp
45 Link with \fI\-lm\fP.
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
53 .BR hypot ():
54 .RS 4
55 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE || _ISOC99_SOURCE ||
56 _POSIX_C_SOURCE\ >=\ 200112L;
57 .br
58 or
59 .I cc\ -std=c99
60 .RE
61 .br
62 .BR hypotf (),
63 .BR hypotl ():
64 .RS 4
65 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
66 _POSIX_C_SOURCE\ >=\ 200112L;
67 .br
68 or
69 .I cc\ -std=c99
70 .RE
71 .ad b
72 .SH DESCRIPTION
73 The
74 .BR hypot ()
75 function returns
76 .RI sqrt( x * x + y * y ).
77 This is the length of the hypotenuse of a right-angled triangle
78 with sides of length
79 .I x
80 and
81 .IR y ,
82 or the distance of the point
83 .RI ( x , y )
84 from the origin.
85
86 The calculation is performed without undue overflow or underflow
87 during the intermediate steps of the calculation.
88 .\" e.g., hypot(DBL_MIN, DBL_MIN) does the right thing, as does, say
89 .\" hypot(DBL_MAX/2.0, DBL_MAX/2.0).
90 .SH RETURN VALUE
91 On success, these functions return the length of a right-angled triangle
92 with sides of length
93 .I x
94 and
95 .IR y .
96
97 If
98 .I x
99 or
100 .I y
101 is an infinity,
102 positive infinity is returned.
103
104 If
105 .I x
106 or
107 .I y
108 is a NaN,
109 and the other argument is not an infinity,
110 a NaN is returned.
111
112 If the result overflows,
113 a range error occurs,
114 and the functions return
115 .BR HUGE_VAL ,
116 .BR HUGE_VALF ,
117 or
118 .BR HUGE_VALL ,
119 respectively.
120
121 If both arguments are subnormal, and the result is subnormal,
122 .\" Actually, could the result not be subnormal if both arguments
123 .\" are subnormal?  I think not -- mtk, Jul 2008
124 a range error occurs,
125 and the correct result is returned.
126 .SH ERRORS
127 See
128 .BR math_error (7)
129 for information on how to determine whether an error has occurred
130 when calling these functions.
131 .PP
132 The following errors can occur:
133 .TP
134 Range error: result overflow
135 .I errno
136 is set to
137 .BR ERANGE .
138 An overflow floating-point exception
139 .RB ( FE_OVERFLOW )
140 is raised.
141 .TP
142 Range error: result underflow
143 .\" .I errno
144 .\" is set to
145 .\" .BR ERANGE .
146 An underflow floating-point exception
147 .RB ( FE_UNDERFLOW )
148 is raised.
149 .IP
150 These functions do not set
151 .IR errno
152 for this case.
153 .\" FIXME . Is it intentional that these functions do not set errno?
154 .\" They do set errno for the overflow case.
155 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6795
156 .SH "CONFORMING TO"
157 C99, POSIX.1-2001.
158 The variant returning
159 .I double
160 also conforms to
161 SVr4, 4.3BSD.
162 .SH "SEE ALSO"
163 .BR cabs (3),
164 .BR sqrt (3)