1POW(3)                     Linux Programmer's Manual                    POW(3)
2
3
4

NAME

6       pow, powf, powl - power functions
7

SYNOPSIS

9       #include <math.h>
10
11       double pow(double x, double y);
12       float powf(float x, float y);
13       long double powl(long double x, long double y);
14
15       Link with -lm.
16
17   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19       powf(), powl():
20           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
21               || /* Since glibc 2.19: */ _DEFAULT_SOURCE
22               || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
23

DESCRIPTION

25       These functions return the value of x raised to the power of y.
26

RETURN VALUE

28       On success, these functions return the value of x to the power of y.
29
30       If x is a finite value less than 0, and y is a finite noninteger, a do‐
31       main error occurs, and a NaN is returned.
32
33       If the result overflows, a range error occurs, and the functions return
34       HUGE_VAL,  HUGE_VALF,  or  HUGE_VALL, respectively, with the mathemati‐
35       cally correct sign.
36
37       If result underflows, and is not representable, a range  error  occurs,
38       and 0.0 is returned.
39
40       Except as specified below, if x or y is a NaN, the result is a NaN.
41
42       If x is +1, the result is 1.0 (even if y is a NaN).
43
44       If y is 0, the result is 1.0 (even if x is a NaN).
45
46       If  x is +0 (-0), and y is an odd integer greater than 0, the result is
47       +0 (-0).
48
49       If x is 0, and y greater than 0 and not an odd integer, the  result  is
50       +0.
51
52       If x is -1, and y is positive infinity or negative infinity, the result
53       is 1.0.
54
55       If the absolute value of x is less than 1, and y is negative  infinity,
56       the result is positive infinity.
57
58       If  the absolute value of x is greater than 1, and y is negative infin‐
59       ity, the result is +0.
60
61       If the absolute value of x is less than 1, and y is positive  infinity,
62       the result is +0.
63
64       If  the absolute value of x is greater than 1, and y is positive infin‐
65       ity, the result is positive infinity.
66
67       If x is negative infinity, and y is an odd integer less than 0, the re‐
68       sult is -0.
69
70       If  x  is  negative infinity, and y less than 0 and not an odd integer,
71       the result is +0.
72
73       If x is negative infinity, and y is an odd integer greater than 0,  the
74       result is negative infinity.
75
76       If x is negative infinity, and y greater than 0 and not an odd integer,
77       the result is positive infinity.
78
79       If x is positive infinity, and y less than 0, the result is +0.
80
81       If x is positive infinity, and y greater than 0, the result is positive
82       infinity.
83
84       If x is +0 or -0, and y is an odd integer less than 0, a pole error oc‐
85       curs and HUGE_VAL, HUGE_VALF, or HUGE_VALL, is returned, with the  same
86       sign as x.
87
88       If  x  is +0 or -0, and y is less than 0 and not an odd integer, a pole
89       error occurs and +HUGE_VAL, +HUGE_VALF, or +HUGE_VALL, is returned.
90

ERRORS

92       See math_error(7) for information on how to determine whether an  error
93       has occurred when calling these functions.
94
95       The following errors can occur:
96
97       Domain error: x is negative, and y is a finite noninteger
98              errno  is  set  to  EDOM.   An  invalid floating-point exception
99              (FE_INVALID) is raised.
100
101       Pole error: x is zero, and y is negative
102              errno is set to ERANGE (but see BUGS).  A divide-by-zero  float‐
103              ing-point exception (FE_DIVBYZERO) is raised.
104
105       Range error: the result overflows
106              errno  is  set  to ERANGE.  An overflow floating-point exception
107              (FE_OVERFLOW) is raised.
108
109       Range error: the result underflows
110              errno is set to ERANGE.  An underflow  floating-point  exception
111              (FE_UNDERFLOW) is raised.
112

ATTRIBUTES

114       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
115       tributes(7).
116
117       ┌────────────────────────────────────────────┬───────────────┬─────────┐
118Interface                                   Attribute     Value   
119       ├────────────────────────────────────────────┼───────────────┼─────────┤
120pow(), powf(), powl()                       │ Thread safety │ MT-Safe │
121       └────────────────────────────────────────────┴───────────────┴─────────┘
122

CONFORMING TO

124       C99, POSIX.1-2001, POSIX.1-2008.
125
126       The variant returning double also conforms to SVr4, 4.3BSD, C89.
127

BUGS

129   Historical bugs (now fixed)
130       Before glibc 2.28, on some architectures (e.g., x86-64)  pow()  may  be
131       more than 10,000 times slower for some inputs than for other nearby in‐
132       puts.  This affects only pow(), and not powf() nor powl().  This  prob‐
133       lem was fixed in glibc 2.28.
134
135       A  number  of  bugs  in the glibc implementation of pow() were fixed in
136       glibc version 2.16.
137
138       In glibc 2.9 and earlier, when a pole error occurs,  errno  is  set  to
139       EDOM  instead  of the POSIX-mandated ERANGE.  Since version 2.10, glibc
140       does the right thing.
141
142       In version 2.3.2 and earlier, when an overflow or underflow  error  oc‐
143       curs,  glibc's pow() generates a bogus invalid floating-point exception
144       (FE_INVALID) in addition to the overflow or underflow exception.
145

SEE ALSO

147       cbrt(3), cpow(3), sqrt(3)
148

COLOPHON

150       This page is part of release 5.13 of the Linux  man-pages  project.   A
151       description  of  the project, information about reporting bugs, and the
152       latest    version    of    this    page,    can     be     found     at
153       https://www.kernel.org/doc/man-pages/.
154
155
156
157                                  2021-03-22                            POW(3)
Impressum