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