getconf: don't include xpg4 bits, gcc7 includes xpg6 bits for us
[unleashed.git] / share / man / man3m / pow.3m
blob320134eeeef60f79e20b1bd6792c8afc0a8b4d05
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
44 .\" Copyright (c) 2001, The IEEE and The Open Group.  All Rights Reserved.
45 .\" Portions Copyright (c) 2006, Sun Microsystems, Inc.  All Rights Reserved.
46 .\"
47 .TH POW 3M "Jul 12, 2006" "SunOS 5.11" "Mathematical Library Functions"
48 .SH NAME
49 pow, powf, powl \- power function
50 .SH SYNOPSIS
51 .LP
52 .nf
53 c99 [ \fIflag\fR... ] \fIfile\fR... \fB-lm\fR [ \fIlibrary\fR... ]
54 #include <math.h>
56 \fBdouble\fR \fBpow\fR(\fBdouble\fR x, \fBdouble\fR y);
57 .fi
59 .LP
60 .nf
61 \fBfloat\fR \fBpowf\fR(\fBfloat\fR x, \fBfloat\fR y);
62 .fi
64 .LP
65 .nf
66 \fBlong double\fR \fBpowl\fR(\fBlong double\fR x, \fBlong double\fR y);
67 .fi
69 .LP
70 .nf
71 cc [ \fIflag\fR... ] \fIfile\fR... \fB-lm\fR [ \fIlibrary\fR... ]
72 #include <math.h>
74 \fBdouble\fR \fBpow\fR(\fBdouble\fR x, \fBdouble\fR y);
75 .fi
77 .LP
78 .nf
79 \fBfloat\fR \fBpowf\fR(\fBfloat\fR x, \fBfloat\fR y);
80 .fi
82 .LP
83 .nf
84 \fBlong double\fR \fBpowl\fR(\fBlong double\fR x, \fBlong double\fR y);
85 .fi
87 .SH DESCRIPTION
88 .sp
89 .LP
90 These functions compute the value of \fIx\fR raised to the power \fIy,\fR
91 \fIx\fR^y>. If \fIx\fR is negative, \fIy\fR must be an integer value.
92 .SH RETURN VALUES
93 .sp
94 .LP
95 Upon successful completion, these functions return the value of \fIx\fR raised
96 to the power \fIy\fR.
97 .sp
98 .LP
99 For finite values of \fIx\fR < 0, and finite non-integer values of \fIy\fR, a
100 domain error occurs and either a NaN (if representable), or an
101 implementation-defined value is returned.
104 If the correct value would cause overflow, a range error occurs and
105 \fBpow()\fR, \fBpowf()\fR, and \fBpowl()\fR return \fBHUGE_VAL\fR,
106 \fBHUGE_VALF\fR, and \fBHUGE_VALL\fR, respectively.
109 If \fIx\fR or \fIy\fR is a NaN, a NaN is returned unless:
110 .RS +4
112 .ie t \(bu
113 .el o
114 If \fIx\fR is +1 and \fIy\fR is NaN and the application was compiled with the
115 \fBc99\fR compiler driver and is therefore SUSv3-conforming (see
116 \fBstandards\fR(5)), 1.0 is returned.
118 .RS +4
120 .ie t \(bu
121 .el o
122 For any value of \fIx\fR (including NaN), if \fIy\fR is +0, 1.0 is returned.
126 For any odd integer value of \fIy\fR > 0, if \fIx\fR is \(+-0, \(+-0 is
127 returned.
130 For \fIy\fR > 0 and not an odd integer, if \fIx\fR is \(+-0, +0 is returned.
133 If \fIx\fR is \(+-1 and \fIy\fR is \(+-Inf, and the application was compiled
134 with the \fBcc\fR compiler driver, NaN is returned. If, however, the
135 application was compiled with the \fBc99\fR compiler driver and is therefore
136 SUSv3-conforming (see \fBstandards\fR(5)), 1.0 is returned.
139 For |\fIx\fR| < 1, if \fIy\fR is \(miInf, +Inf is returned.
142 For |\fIx\fR| > 1, if \fIy\fR is \(miInf, +0 is returned.
145 For |\fIx\fR| < 1, if \fIy\fR is +Inf, +0 is returned.
148 For |\fIx\fR| > 1, if \fIy\fR is +Inf, +Inf is returned.
151 For \fIy\fR an odd integer < 0, if \fIx\fR is \(miInf, \(mi0 is returned.
154 For \fIy\fR < 0 and not an odd integer, if \fIx\fR is \(miInf, +0 is returned.
157 For \fIy\fR an odd integer > 0, if \fIx\fR is \(miInf, \(miInf is returned.
160 For \fIy\fR > 0 and not an odd integer, if \fIx\fR is \(miInf, +Inf is
161 returned.
164 For \fIy\fR < 0, if \fIx\fR is +Inf, +0 is returned.
167 For \fIy\fR > 0, if \fIx\fR is +Inf, +Inf is returned.
170 For \fIy\fR an odd integer < 0, if \fIx\fR is \(+-0, a pole error occurs and
171 \(+-\fBHUGE_VAL\fR, \(+-\fBHUGE_VALF\fR, and \(+-\fBHUGE_VALL\fR are returned
172 for \fBpow()\fR, \fBpowf()\fR, and \fBpowl()\fR, respectively.
175 For \fIy\fR < 0 and not an odd integer, if \fIx\fR is \(+-0, a pole error
176 occurs and \fBHUGE_VAL\fR, \fBHUGE_VALF\fR, and \fBHUGE_VALL\fR are returned
177 for \fBpow()\fR, \fBpowf()\fR, and \fBpowl()\fR, respectively.
180 For exceptional cases, \fBmatherr\fR(3M) tabulates the values to be returned by
181 \fBpow()\fR as specified by SVID3 and XPG3.
182 .SH ERRORS
185 These functions will fail if:
187 .ne 2
190 \fBDomain Error\fR
192 .RS 16n
194 The value of \fIx\fR is negative and \fIy\fR is a finite non-integer.
196 If the integer expression (\fBmath_errhandling\fR & \fBMATH_ERREXCEPT\fR) is
197 non-zero, the invalid floating-point exception is raised.
199 The \fBpow()\fR function sets \fBerrno\fR to \fBEDOM\fR if the value of \fIx\fR
200 is negative and \fIy\fR is non-integral.
204 .ne 2
207 \fBPole Error\fR
209 .RS 16n
211 The value of \fIx\fR is 0 and \fIy\fR is negative.
213 If the integer expression (\fBmath_errhandling\fR & \fBMATH_ERREXCEPT\fR) is
214 non-zero, the divide-by-zero floating-point exception is raised.
218 .ne 2
221 \fBRange Error\fR
223 .RS 16n
225 The result overflows.
227 If the integer expression (\fBmath_errhandling\fR & \fBMATH_ERREXCEPT\fR) is
228 non-zero, the overflow floating-point exception is raised.
230 The \fBpow()\fR function sets \fBerrno\fR to \fBEDOM\fR if the value to be
231 returned would cause overflow.
234 .SH USAGE
237 An application wanting to check for exceptions should call
238 \fBfeclearexcept\fR(\fBFE_ALL_EXCEPT\fR) before calling these functions. On
239 return, if \fBfetestexcept\fR(\fBFE_INVALID\fR | \fBFE_DIVBYZERO\fR |
240 \fBFE_OVERFLOW\fR | \fBFE_UNDERFLOW\fR) is non-zero, an exception has been
241 raised. An application should either examine the return value or check the
242 floating point exception flags to detect exceptions.
245 An application can also set \fBerrno\fR to 0 before calling \fBpow()\fR. On
246 return, if \fBerrno\fR is non-zero, an error has occurred. The \fBpowf()\fR and
247 \fBpowl()\fR functions do not set \fBerrno\fR.
248 .SH ATTRIBUTES
251 See \fBattributes\fR(5) for descriptions of the following attributes:
256 tab(    ) box;
257 cw(2.75i) |cw(2.75i)
258 lw(2.75i) |lw(2.75i)
260 ATTRIBUTE TYPE  ATTRIBUTE VALUE
262 Interface Stability     Standard
264 MT-Level        MT-Safe
267 .SH SEE ALSO
270 \fBexp\fR(3M), \fBfeclearexcept\fR(3M), \fBfetestexcept\fR(3M),
271 \fBisnan\fR(3M), \fBmath.h\fR(3HEAD), \fBmatherr\fR(3M), \fBattributes\fR(5),
272 \fBstandards\fR(5)
273 .SH NOTES
276 Prior to Solaris 2.6,  there was a conflict between the \fBpow()\fR function in
277 this library and the \fBpow()\fR function in the \fBlibmp\fR library. This
278 conflict was resolved by prepending \fBmp_\fR to all functions in the
279 \fBlibmp\fR library. See \fBmp\fR(3MP) for more information.