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 2017-09-15 "" "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)):
58 _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
59 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
60 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
64 These functions return the value of
70 On success, these functions return the value of
77 is a finite value less than 0, and
79 is a finite noninteger, a domain error occurs,
80 .\" The domain error is generated at least as far back as glibc 2.4
81 and a NaN is returned.
83 If the result overflows,
85 .\" The range error is generated at least as far back as glibc 2.4
86 and the functions return
91 respectively, with the mathematically correct sign.
93 If result underflows, and is not representable,
96 .\" POSIX.1 does not specify the sign of the zero,
97 .\" but http://sources.redhat.com/bugzilla/show_bug.cgi?id=2678
98 .\" points out that the zero has the wrong sign in some cases.
100 Except as specified below, if
104 is a NaN, the result is a NaN.
108 is +1, the result is 1.0 (even if
114 is 0, the result is 1.0 (even if
123 is an odd integer greater than 0,
124 the result is +0 (\-0).
131 greater than 0 and not an odd integer,
139 is positive infinity or negative infinity,
142 If the absolute value of
147 is negative infinity,
148 the result is positive infinity.
150 If the absolute value of
155 is negative infinity,
158 If the absolute value of
163 is positive infinity,
166 If the absolute value of
171 is positive infinity,
172 the result is positive infinity.
176 is negative infinity,
179 is an odd integer less than 0,
184 is negative infinity,
187 less than 0 and not an odd integer,
192 is negative infinity,
195 is an odd integer greater than 0,
196 the result is negative infinity.
200 is negative infinity,
203 greater than 0 and not an odd integer,
204 the result is positive infinity.
208 is positive infinity,
216 is positive infinity,
220 the result is positive infinity.
227 is an odd integer less than 0,
228 a pole error occurs and
234 with the same sign as
242 is less than 0 and not an odd integer,
243 a pole error occurs and
244 .\" The pole error is generated at least as far back as glibc 2.4
251 .\" FIXME . review status of this error
252 .\" longstanding bug report for glibc:
253 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=369
254 .\" For negative x, and -large and +large y, glibc 2.8 gives incorrect
256 .\" pow(-0.5,-DBL_MAX)=nan
257 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
258 .\" FAIL (expected: range-error-overflow (ERANGE, FE_OVERFLOW); +INF)
260 .\" pow(-1.5,-DBL_MAX)=nan
261 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
262 .\" FAIL (expected: range-error-underflow (ERANGE, FE_UNDERFLOW); +0)
264 .\" pow(-0.5,DBL_MAX)=nan
265 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
266 .\" FAIL (expected: range-error-underflow (ERANGE, FE_UNDERFLOW); +0)
268 .\" pow(-1.5,DBL_MAX)=nan
269 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
270 .\" FAIL (expected: range-error-overflow (ERANGE, FE_OVERFLOW); +INF)
273 for information on how to determine whether an error has occurred
274 when calling these functions.
276 The following errors can occur:
278 Domain error: \fIx\fP is negative, and \fIy\fP is a finite noninteger
282 An invalid floating-point exception
286 Pole error: \fIx\fP is zero, and \fIy\fP is negative
291 A divide-by-zero floating-point exception
295 Range error: the result overflows
299 An overflow floating-point exception
303 Range error: the result underflows
307 An underflow floating-point exception
311 For an explanation of the terms used in this section, see
317 Interface Attribute Value
322 T} Thread safety MT-Safe
325 C99, POSIX.1-2001, POSIX.1-2008.
327 The variant returning
334 .\" https://sourceware.org/bugzilla/show_bug.cgi?id=13932
336 may be more than 10,000 times slower for some (rare) inputs
337 than for other nearby inputs.
345 In glibc 2.9 and earlier,
347 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6776
348 when a pole error occurs,
352 instead of the POSIX-mandated
355 .\" or possibly 2.9, I haven't found the source code change
356 .\" and I don't have a 2.9 system to test
357 glibc does the right thing.
362 then large negative or positive
364 values yield a NaN as the function result, with
370 floating-point exception.
373 one sees this behavior when the absolute value of
375 is greater than about 9.223373e18.
376 .\" see bug http://sources.redhat.com/bugzilla/show_bug.cgi?id=3866
377 .\" and http://sources.redhat.com/bugzilla/show_bug.cgi?id=369
379 In version 2.3.2 and earlier,
380 .\" FIXME . Actually, 2.3.2 is the earliest test result I have; so yet
381 .\" to confirm if this error occurs only in 2.3.2.
382 when an overflow or underflow error occurs, glibc's
384 generates a bogus invalid floating-point exception
386 in addition to the overflow or underflow exception.