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
11

NAME

13       pow, powf, powl — power function
14

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

150       None.
151

APPLICATION USAGE

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

RATIONALE

158       None.
159

FUTURE DIRECTIONS

161       None.
162

SEE ALSO

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