logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

pow.3p (7357B)


  1. '\" et
  2. .TH POW "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. pow,
  12. powf,
  13. powl
  14. \(em power function
  15. .SH SYNOPSIS
  16. .LP
  17. .nf
  18. #include <math.h>
  19. .P
  20. double pow(double \fIx\fP, double \fIy\fP);
  21. float powf(float \fIx\fP, float \fIy\fP);
  22. long double powl(long double \fIx\fP, long double \fIy\fP);
  23. .fi
  24. .SH DESCRIPTION
  25. The functionality described on this reference page is aligned with the
  26. ISO\ C standard. Any conflict between the requirements described here and the
  27. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  28. .P
  29. These functions shall compute the value of
  30. .IR x
  31. raised to the power
  32. .IR y ,
  33. .IR x\u\s-3y\s+3\d .
  34. If
  35. .IR x
  36. is negative, the application shall ensure that
  37. .IR y
  38. is an integer value.
  39. .P
  40. An application wishing to check for error situations should set
  41. .IR errno
  42. to zero and call
  43. .IR feclearexcept (FE_ALL_EXCEPT)
  44. before calling these functions. On return, if
  45. .IR errno
  46. is non-zero or \fIfetestexcept\fR(FE_INVALID | FE_DIVBYZERO |
  47. FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred.
  48. .SH "RETURN VALUE"
  49. Upon successful completion, these functions shall return the value of
  50. .IR x
  51. raised to the power
  52. .IR y .
  53. .P
  54. For finite values of
  55. .IR x
  56. < 0, and finite non-integer values of
  57. .IR y ,
  58. a domain error shall occur and
  59. either a NaN (if representable), or
  60. an implementation-defined value shall be returned.
  61. .P
  62. If the correct value would cause overflow, a range error shall occur
  63. and
  64. \fIpow\fR(),
  65. \fIpowf\fR(),
  66. and
  67. \fIpowl\fR()
  68. shall return \(+-HUGE_VAL, \(+-HUGE_VALF, and \(+-HUGE_VALL,
  69. respectively, with the same sign as the correct value of the function.
  70. .P
  71. If the correct value would cause underflow,
  72. and is not representable,
  73. a range error may occur, and
  74. \fIpow\fR(),
  75. \fIpowf\fR(),
  76. and
  77. \fIpowl\fR()
  78. shall return
  79. 0.0, or
  80. (if IEC 60559 Floating-Point is not supported) an implementation-defined
  81. value no greater in magnitude than DBL_MIN, FLT_MIN, and LDBL_MIN,
  82. respectively.
  83. .P
  84. For
  85. .IR y
  86. < 0, if
  87. .IR x
  88. is zero, a
  89. pole
  90. error may occur and
  91. \fIpow\fR(),
  92. \fIpowf\fR(),
  93. and
  94. \fIpowl\fR()
  95. shall return \(+-HUGE_VAL, \(+-HUGE_VALF, and \(+-HUGE_VALL, respectively.
  96. On systems that support the IEC 60559 Floating-Point option, if
  97. .IR x
  98. is \(+-0, a pole error shall occur and
  99. \fIpow\fR(),
  100. \fIpowf\fR(),
  101. and
  102. \fIpowl\fR()
  103. shall return \(+-HUGE_VAL, \(+-HUGE_VALF, and \(+-HUGE_VALL, respectively
  104. if
  105. .IR y
  106. is an odd integer, or HUGE_VAL, HUGE_VALF, and HUGE_VALL, respectively if
  107. .IR y
  108. is not an odd integer.
  109. .P
  110. If
  111. .IR x
  112. or
  113. .IR y
  114. is a NaN, a NaN shall be returned (unless specified elsewhere in this
  115. description).
  116. .P
  117. For any value of
  118. .IR y
  119. (including NaN), if
  120. .IR x
  121. is +1, 1.0 shall be returned.
  122. .P
  123. For any value of
  124. .IR x
  125. (including NaN), if
  126. .IR y
  127. is \(+-0, 1.0 shall be returned.
  128. .P
  129. For any odd integer value of
  130. .IR y
  131. > 0, if
  132. .IR x
  133. is \(+-0, \(+-0 shall be returned.
  134. .P
  135. For
  136. .IR y
  137. > 0 and not an odd integer, if
  138. .IR x
  139. is \(+-0, +0 shall be returned.
  140. .P
  141. If
  142. .IR x
  143. is \-1, and
  144. .IR y
  145. is \(+-Inf, 1.0 shall be returned.
  146. .P
  147. For |\fIx\fP| < 1, if
  148. .IR y
  149. is \-Inf, +Inf shall be returned.
  150. .P
  151. For |\fIx\fP| > 1, if
  152. .IR y
  153. is \-Inf, +0 shall be returned.
  154. .P
  155. For |\fIx\fP| < 1, if
  156. .IR y
  157. is +Inf, +0 shall be returned.
  158. .P
  159. For |\fIx\fP| > 1, if
  160. .IR y
  161. is +Inf, +Inf shall be returned.
  162. .P
  163. For
  164. .IR y
  165. an odd integer < 0, if
  166. .IR x
  167. is \-Inf, \-0 shall be returned.
  168. .P
  169. For
  170. .IR y
  171. < 0 and not an odd integer, if
  172. .IR x
  173. is \-Inf, +0 shall be returned.
  174. .P
  175. For
  176. .IR y
  177. an odd integer > 0, if
  178. .IR x
  179. is \-Inf, \-Inf shall be returned.
  180. .P
  181. For
  182. .IR y
  183. > 0 and not an odd integer, if
  184. .IR x
  185. is \-Inf, +Inf shall be returned.
  186. .P
  187. For
  188. .IR y
  189. < 0, if
  190. .IR x
  191. is +Inf, +0 shall be returned.
  192. .P
  193. For
  194. .IR y
  195. > 0, if
  196. .IR x
  197. is +Inf, +Inf shall be returned.
  198. .P
  199. If the correct value would cause underflow, and is representable, a
  200. range error may occur and the correct value shall be returned.
  201. .SH ERRORS
  202. These functions shall fail if:
  203. .IP "Domain\ Error" 12
  204. The value of
  205. .IR x
  206. is negative and
  207. .IR y
  208. is a finite non-integer.
  209. .RS 12
  210. .P
  211. If the integer expression (\fImath_errhandling\fR & MATH_ERRNO) is
  212. non-zero, then
  213. .IR errno
  214. shall be set to
  215. .BR [EDOM] .
  216. If the integer expression (\fImath_errhandling\fR & MATH_ERREXCEPT) is
  217. non-zero, then the invalid floating-point exception shall be raised.
  218. .RE
  219. .IP "Pole\ Error" 12
  220. The value of
  221. .IR x
  222. is zero and
  223. .IR y
  224. is negative.
  225. .RS 12
  226. .P
  227. If the integer expression (\fImath_errhandling\fR & MATH_ERRNO) is
  228. non-zero, then
  229. .IR errno
  230. shall be set to
  231. .BR [ERANGE] .
  232. If the integer expression (\fImath_errhandling\fR & MATH_ERREXCEPT) is
  233. non-zero, then the divide-by-zero floating-point exception shall be
  234. raised.
  235. .RE
  236. .IP "Range\ Error" 12
  237. The result overflows.
  238. .RS 12
  239. .P
  240. If the integer expression (\fImath_errhandling\fR & MATH_ERRNO) is
  241. non-zero, then
  242. .IR errno
  243. shall be set to
  244. .BR [ERANGE] .
  245. If the integer expression (\fImath_errhandling\fR & MATH_ERREXCEPT) is
  246. non-zero, then the overflow floating-point exception shall be raised.
  247. .RE
  248. .P
  249. These functions may fail if:
  250. .IP "Pole\ Error" 12
  251. The value of
  252. .IR x
  253. is zero and
  254. .IR y
  255. is negative.
  256. .RS 12
  257. .P
  258. If the integer expression (\fImath_errhandling\fR & MATH_ERRNO) is
  259. non-zero, then
  260. .IR errno
  261. shall be set to
  262. .BR [ERANGE] .
  263. If the integer expression (\fImath_errhandling\fR & MATH_ERREXCEPT) is
  264. non-zero, then the divide-by-zero floating-point exception shall be
  265. raised.
  266. .RE
  267. .IP "Range\ Error" 12
  268. The result underflows.
  269. .RS 12
  270. .P
  271. If the integer expression (\fImath_errhandling\fR & MATH_ERRNO) is
  272. non-zero, then
  273. .IR errno
  274. shall be set to
  275. .BR [ERANGE] .
  276. If the integer expression (\fImath_errhandling\fR & MATH_ERREXCEPT) is
  277. non-zero, then the underflow floating-point exception shall be raised.
  278. .RE
  279. .LP
  280. .IR "The following sections are informative."
  281. .SH EXAMPLES
  282. None.
  283. .SH "APPLICATION USAGE"
  284. On error, the expressions (\fImath_errhandling\fR & MATH_ERRNO) and
  285. (\fImath_errhandling\fR & MATH_ERREXCEPT) are independent of each
  286. other, but at least one of them must be non-zero.
  287. .SH RATIONALE
  288. None.
  289. .SH "FUTURE DIRECTIONS"
  290. None.
  291. .SH "SEE ALSO"
  292. .IR "\fIexp\fR\^(\|)",
  293. .IR "\fIfeclearexcept\fR\^(\|)",
  294. .IR "\fIfetestexcept\fR\^(\|)",
  295. .IR "\fIisnan\fR\^(\|)"
  296. .P
  297. The Base Definitions volume of POSIX.1\(hy2017,
  298. .IR "Section 4.20" ", " "Treatment of Error Conditions for Mathematical Functions",
  299. .IR "\fB<math.h>\fP"
  300. .\"
  301. .SH COPYRIGHT
  302. Portions of this text are reprinted and reproduced in electronic form
  303. from IEEE Std 1003.1-2017, Standard for Information Technology
  304. -- Portable Operating System Interface (POSIX), The Open Group Base
  305. Specifications Issue 7, 2018 Edition,
  306. Copyright (C) 2018 by the Institute of
  307. Electrical and Electronics Engineers, Inc and The Open Group.
  308. In the event of any discrepancy between this version and the original IEEE and
  309. The Open Group Standard, the original IEEE and The Open Group Standard
  310. is the referee document. The original Standard can be obtained online at
  311. http://www.opengroup.org/unix/online.html .
  312. .PP
  313. Any typographical or formatting errors that appear
  314. in this page are most likely
  315. to have been introduced during the conversion of the source files to
  316. man page format. To report such errors, see
  317. https://www.kernel.org/doc/man-pages/reporting_bugs.html .