1POW(3P)                    POSIX Programmer's Manual                   POW(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       pow, powf, powl — power function
13

SYNOPSIS

15       #include <math.h>
16
17       double pow(double x, double y);
18       float powf(float x, float y);
19       long double powl(long double x, long double y);
20

DESCRIPTION

22       The functionality described on this reference page is aligned with  the
23       ISO C  standard.  Any  conflict between the requirements described here
24       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2017
25       defers to the ISO C standard.
26
27       These functions shall compute the value of x raised to the power y, xy.
28       If x is negative, the application shall ensure that  y  is  an  integer
29       value.
30
31       An  application  wishing to check for error situations should set errno
32       to zero and  call  feclearexcept(FE_ALL_EXCEPT)  before  calling  these
33       functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
34       FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero,  an  error  has
35       occurred.
36

RETURN VALUE

38       Upon successful completion, these functions shall return the value of x
39       raised to the power y.
40
41       For finite values of x < 0, and  finite  non-integer  values  of  y,  a
42       domain  error  shall  occur  and either a NaN (if representable), or an
43       implementation-defined value shall be returned.
44
45       If the correct value would cause overflow, a range  error  shall  occur
46       and  pow(),  powf(), and powl() shall return ±HUGE_VAL, ±HUGE_VALF, and
47       ±HUGE_VALL, respectively, with the same sign as the  correct  value  of
48       the function.
49
50       If the correct value would cause underflow, and is not representable, a
51       range error may occur, and pow(), powf(), and powl() shall return  0.0,
52       or  (if  IEC  60559 Floating-Point is not supported) an implementation-
53       defined value no  greater  in  magnitude  than  DBL_MIN,  FLT_MIN,  and
54       LDBL_MIN, respectively.
55
56       For  y < 0, if x is zero, a pole error may occur and pow(), powf(), and
57       powl() shall return  ±HUGE_VAL,  ±HUGE_VALF,  and  ±HUGE_VALL,  respec‐
58       tively.   On  systems that support the IEC 60559 Floating-Point option,
59       if x is ±0, a pole error shall occur  and  pow(),  powf(),  and  powl()
60       shall  return  ±HUGE_VAL, ±HUGE_VALF, and ±HUGE_VALL, respectively if y
61       is an odd integer, or HUGE_VAL, HUGE_VALF, and HUGE_VALL,  respectively
62       if y is not an odd integer.
63
64       If x or y is a NaN, a NaN shall be returned (unless specified elsewhere
65       in this description).
66
67       For any value of y (including NaN), if x is +1, 1.0 shall be returned.
68
69       For any value of x (including NaN), if y is ±0, 1.0 shall be returned.
70
71       For any odd integer value of y > 0, if x is ±0, ±0 shall be returned.
72
73       For y > 0 and not an odd integer, if x is ±0, +0 shall be returned.
74
75       If x is -1, and y is ±Inf, 1.0 shall be returned.
76
77       For |x| < 1, if y is -Inf, +Inf shall be returned.
78
79       For |x| > 1, if y is -Inf, +0 shall be returned.
80
81       For |x| < 1, if y is +Inf, +0 shall be returned.
82
83       For |x| > 1, if y is +Inf, +Inf shall be returned.
84
85       For y an odd integer < 0, if x is -Inf, -0 shall be returned.
86
87       For y < 0 and not an odd integer, if x is -Inf, +0 shall be returned.
88
89       For y an odd integer > 0, if x is -Inf, -Inf shall be returned.
90
91       For y > 0 and not an odd integer, if x is -Inf, +Inf shall be returned.
92
93       For y < 0, if x is +Inf, +0 shall be returned.
94
95       For y > 0, if x is +Inf, +Inf shall be returned.
96
97       If the correct value would cause underflow,  and  is  representable,  a
98       range error may occur and the correct value shall be returned.
99

ERRORS

101       These functions shall fail if:
102
103       Domain Error
104                   The value of x is negative and y is a finite non-integer.
105
106                   If  the  integer expression (math_errhandling & MATH_ERRNO)
107                   is non-zero, then errno shall be set  to  [EDOM].   If  the
108                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
109                   non-zero, then the invalid floating-point  exception  shall
110                   be raised.
111
112       Pole Error  The value of x is zero and y is negative.
113
114                   If  the  integer expression (math_errhandling & MATH_ERRNO)
115                   is non-zero, then errno shall be set to [ERANGE].   If  the
116                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
117                   non-zero, then the divide-by-zero floating-point  exception
118                   shall be raised.
119
120       Range Error The result overflows.
121
122                   If  the  integer expression (math_errhandling & MATH_ERRNO)
123                   is non-zero, then errno shall be set to [ERANGE].   If  the
124                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
125                   non-zero, then the overflow floating-point exception  shall
126                   be raised.
127
128       These functions may fail if:
129
130       Pole Error  The value of x is zero and y is negative.
131
132                   If  the  integer expression (math_errhandling & MATH_ERRNO)
133                   is non-zero, then errno shall be set to [ERANGE].   If  the
134                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
135                   non-zero, then the divide-by-zero floating-point  exception
136                   shall be raised.
137
138       Range Error The result underflows.
139
140                   If  the  integer expression (math_errhandling & MATH_ERRNO)
141                   is non-zero, then errno shall be set to [ERANGE].   If  the
142                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
143                   non-zero, then the underflow floating-point exception shall
144                   be raised.
145
146       The following sections are informative.
147

EXAMPLES

149       None.
150

APPLICATION USAGE

152       On   error,   the   expressions  (math_errhandling  &  MATH_ERRNO)  and
153       (math_errhandling & MATH_ERREXCEPT) are independent of each other,  but
154       at least one of them must be non-zero.
155

RATIONALE

157       None.
158

FUTURE DIRECTIONS

160       None.
161

SEE ALSO

163       exp(), feclearexcept(), fetestexcept(), isnan()
164
165       The Base Definitions volume of POSIX.1‐2017, Section 4.20, Treatment of
166       Error Conditions for Mathematical Functions, <math.h>
167
169       Portions of this text are reprinted and reproduced in  electronic  form
170       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
171       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
172       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
173       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
174       event of any discrepancy between this version and the original IEEE and
175       The Open Group Standard, the original IEEE and The Open Group  Standard
176       is  the  referee document. The original Standard can be obtained online
177       at http://www.opengroup.org/unix/online.html .
178
179       Any typographical or formatting errors that appear  in  this  page  are
180       most likely to have been introduced during the conversion of the source
181       files to man page format. To report such errors,  see  https://www.ker
182       nel.org/doc/man-pages/reporting_bugs.html .
183
184
185
186IEEE/The Open Group                  2017                              POW(3P)
Impressum