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 2016-03-15 "" "Linux Programmer's Manual"
37 pow, powf, powl \- power functions
42 .BI "double pow(double " x ", double " y );
44 .BI "float powf(float " x ", float " y );
46 .BI "long double powl(long double " x ", long double " y );
52 Feature Test Macro Requirements for glibc (see
53 .BR feature_test_macros (7)):
60 _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
61 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
62 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
66 These functions return the value of
72 On success, these functions return the value of
79 is a finite value less than 0, and
81 is a finite noninteger, a domain error occurs,
82 .\" The domain error is generated at least as far back as glibc 2.4
83 and a NaN is returned.
85 If the result overflows,
87 .\" The range error is generated at least as far back as glibc 2.4
88 and the functions return
93 respectively, with the mathematically correct sign.
95 If result underflows, and is not representable,
98 .\" POSIX.1 does not specify the sign of the zero,
99 .\" but http://sources.redhat.com/bugzilla/show_bug.cgi?id=2678
100 .\" points out that the zero has the wrong sign in some cases.
102 Except as specified below, if
106 is a NaN, the result is a NaN.
110 is +1, the result is 1.0 (even if
116 is 0, the result is 1.0 (even if
125 is an odd integer greater than 0,
126 the result is +0 (\-0).
133 greater than 0 and not an odd integer,
141 is positive infinity or negative infinity,
144 If the absolute value of
149 is negative infinity,
150 the result is positive infinity.
152 If the absolute value of
157 is negative infinity,
160 If the absolute value of
165 is positive infinity,
168 If the absolute value of
173 is positive infinity,
174 the result is positive infinity.
178 is negative infinity,
181 is an odd integer less than 0,
186 is negative infinity,
189 less than 0 and not an odd integer,
194 is negative infinity,
197 is an odd integer greater than 0,
198 the result is negative infinity.
202 is negative infinity,
205 greater than 0 and not an odd integer,
206 the result is positive infinity.
210 is positive infinity,
218 is positive infinity,
222 the result is positive infinity.
229 is an odd integer less than 0,
230 a pole error occurs and
236 with the same sign as
244 is less than 0 and not an odd integer,
245 a pole error occurs and
246 .\" The pole error is generated at least as far back as glibc 2.4
253 .\" FIXME . review status of this error
254 .\" longstanding bug report for glibc:
255 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=369
256 .\" For negative x, and -large and +large y, glibc 2.8 gives incorrect
258 .\" pow(-0.5,-DBL_MAX)=nan
259 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
260 .\" FAIL (expected: range-error-overflow (ERANGE, FE_OVERFLOW); +INF)
262 .\" pow(-1.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(-0.5,DBL_MAX)=nan
267 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
268 .\" FAIL (expected: range-error-underflow (ERANGE, FE_UNDERFLOW); +0)
270 .\" pow(-1.5,DBL_MAX)=nan
271 .\" EDOM FE_INVALID nan; fail-errno fail-except fail-result;
272 .\" FAIL (expected: range-error-overflow (ERANGE, FE_OVERFLOW); +INF)
275 for information on how to determine whether an error has occurred
276 when calling these functions.
278 The following errors can occur:
280 Domain error: \fIx\fP is negative, and \fIy\fP is a finite noninteger
284 An invalid floating-point exception
288 Pole error: \fIx\fP is zero, and \fIy\fP is negative
293 A divide-by-zero floating-point exception
297 Range error: the result overflows
301 An overflow floating-point exception
305 Range error: the result underflows
309 An underflow floating-point exception
313 For an explanation of the terms used in this section, see
319 Interface Attribute Value
324 T} Thread safety MT-Safe
327 C99, POSIX.1-2001, POSIX.1-2008.
329 The variant returning
336 .\" https://sourceware.org/bugzilla/show_bug.cgi?id=13932
338 may be more than 10,000 times slower for some (rare) inputs
339 than for other nearby inputs.
347 In glibc 2.9 and earlier,
349 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6776
350 when a pole error occurs,
354 instead of the POSIX-mandated
357 .\" or possibly 2.9, I haven't found the source code change
358 .\" and I don't have a 2.9 system to test
359 glibc does the right thing.
364 then large negative or positive
366 values yield a NaN as the function result, with
372 floating-point exception.
375 one sees this behavior when the absolute value of
377 is greater than about 9.223373e18.
378 .\" see bug http://sources.redhat.com/bugzilla/show_bug.cgi?id=3866
379 .\" and http://sources.redhat.com/bugzilla/show_bug.cgi?id=369
381 In version 2.3.2 and earlier,
382 .\" FIXME . Actually, 2.3.2 is the earliest test result I have; so yet
383 .\" to confirm if this error occurs only in 2.3.2.
384 when an overflow or underflow error occurs, glibc's
386 generates a bogus invalid floating-point exception
388 in addition to the overflow or underflow exception.