1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
27 .\" References consulted:
28 .\" Linux libc source code
29 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
31 .\" Modified 1993-07-24 by Rik Faith (faith@cs.unc.edu)
32 .\" Modified 1995-08-14 by Arnt Gulbrandsen <agulbra@troll.no>
33 .\" Modified 2002-07-27 by Walter Harms
34 .\" (walter.harms@informatik.uni-oldenburg.de)
35 .TH POW 3 2021-03-22 "" "Linux Programmer's Manual"
37 pow, powf, powl \- power functions
42 .BI "double pow(double " x ", double " y );
43 .BI "float powf(float " x ", float " y );
44 .BI "long double powl(long double " x ", long double " y );
50 Feature Test Macro Requirements for glibc (see
51 .BR feature_test_macros (7)):
57 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
58 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
59 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
62 These functions return the value of
68 On success, these functions return the value of
75 is a finite value less than 0, and
77 is a finite noninteger, a domain error occurs,
78 .\" The domain error is generated at least as far back as glibc 2.4
79 and a NaN is returned.
81 If the result overflows,
83 .\" The range error is generated at least as far back as glibc 2.4
84 and the functions return
89 respectively, with the mathematically correct sign.
91 If result underflows, and is not representable,
94 .\" POSIX.1 does not specify the sign of the zero,
95 .\" but http://sources.redhat.com/bugzilla/show_bug.cgi?id=2678
96 .\" points out that the zero has the wrong sign in some cases.
98 Except as specified below, if
102 is a NaN, the result is a NaN.
106 is +1, the result is 1.0 (even if
112 is 0, the result is 1.0 (even if
121 is an odd integer greater than 0,
122 the result is +0 (\-0).
129 greater than 0 and not an odd integer,
137 is positive infinity or negative infinity,
140 If the absolute value of
145 is negative infinity,
146 the result is positive infinity.
148 If the absolute value of
153 is negative infinity,
156 If the absolute value of
161 is positive infinity,
164 If the absolute value of
169 is positive infinity,
170 the result is positive infinity.
174 is negative infinity,
177 is an odd integer less than 0,
182 is negative infinity,
185 less than 0 and not an odd integer,
190 is negative infinity,
193 is an odd integer greater than 0,
194 the result is negative infinity.
198 is negative infinity,
201 greater than 0 and not an odd integer,
202 the result is positive infinity.
206 is positive infinity,
214 is positive infinity,
218 the result is positive infinity.
225 is an odd integer less than 0,
226 a pole error occurs and
232 with the same sign as
240 is less than 0 and not an odd integer,
241 a pole error occurs and
242 .\" The pole error is generated at least as far back as glibc 2.4
249 .\" FIXME . review status of this error
250 .\" longstanding bug report for glibc:
251 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=369
252 .\" For negative x, and -large and +large y, glibc 2.8 gives incorrect
254 .\" pow(-0.5,-DBL_MAX)=nan
255 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
256 .\" FAIL (expected: range-error-overflow (ERANGE, FE_OVERFLOW); +INF)
258 .\" pow(-1.5,-DBL_MAX)=nan
259 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
260 .\" FAIL (expected: range-error-underflow (ERANGE, FE_UNDERFLOW); +0)
262 .\" pow(-0.5,DBL_MAX)=nan
263 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
264 .\" FAIL (expected: range-error-underflow (ERANGE, FE_UNDERFLOW); +0)
266 .\" pow(-1.5,DBL_MAX)=nan
267 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
268 .\" FAIL (expected: range-error-overflow (ERANGE, FE_OVERFLOW); +INF)
271 for information on how to determine whether an error has occurred
272 when calling these functions.
274 The following errors can occur:
276 Domain error: \fIx\fP is negative, and \fIy\fP is a finite noninteger
280 An invalid floating-point exception
284 Pole error: \fIx\fP is zero, and \fIy\fP is negative
289 A divide-by-zero floating-point exception
293 Range error: the result overflows
297 An overflow floating-point exception
301 Range error: the result underflows
305 An underflow floating-point exception
309 For an explanation of the terms used in this section, see
317 Interface Attribute Value
322 T} Thread safety MT-Safe
328 C99, POSIX.1-2001, POSIX.1-2008.
330 The variant returning
335 .SS Historical bugs (now fixed)
337 .\" https://sourceware.org/bugzilla/show_bug.cgi?id=13932
338 on some architectures (e.g., x86-64)
340 may be more than 10,000 times slower for some inputs
341 than for other nearby inputs.
348 This problem was fixed
349 .\" commit c3d466cba1692708a19c6ff829d0386c83a0c6e5
353 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=3866
354 in the glibc implementation of
356 were fixed in glibc version 2.16.
358 In glibc 2.9 and earlier,
360 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6776
361 when a pole error occurs,
365 instead of the POSIX-mandated
368 .\" or possibly 2.9, I haven't found the source code change
369 .\" and I don't have a 2.9 system to test
370 glibc does the right thing.
372 In version 2.3.2 and earlier,
373 .\" Actually, 2.3.2 is the earliest test result I have; so yet
374 .\" to confirm if this error occurs only in 2.3.2.
375 when an overflow or underflow error occurs, glibc's
377 generates a bogus invalid floating-point exception
379 in addition to the overflow or underflow exception.