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

exp.3p (4705B)


  1. '\" et
  2. .TH EXP "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. exp,
  12. expf,
  13. expl
  14. \(em exponential function
  15. .SH SYNOPSIS
  16. .LP
  17. .nf
  18. #include <math.h>
  19. .P
  20. double exp(double \fIx\fP);
  21. float expf(float \fIx\fP);
  22. long double expl(long double \fIx\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 base-\c
  30. .IR e
  31. exponential of
  32. .IR x .
  33. .P
  34. An application wishing to check for error situations should set
  35. .IR errno
  36. to zero and call
  37. .IR feclearexcept (FE_ALL_EXCEPT)
  38. before calling these functions. On return, if
  39. .IR errno
  40. is non-zero or \fIfetestexcept\fR(FE_INVALID | FE_DIVBYZERO |
  41. FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred.
  42. .SH "RETURN VALUE"
  43. Upon successful completion, these functions shall return the
  44. exponential value of
  45. .IR x .
  46. .P
  47. If the correct value would cause overflow, a range error shall occur
  48. and
  49. \fIexp\fR(),
  50. \fIexpf\fR(),
  51. and
  52. \fIexpl\fR()
  53. shall return the value of the macro HUGE_VAL, HUGE_VALF, and HUGE_VALL,
  54. respectively.
  55. .P
  56. If the correct value would cause underflow,
  57. and is not representable,
  58. a range error may occur, and
  59. \fIexp\fR(),
  60. \fIexpf\fR(),
  61. and
  62. \fIexpl\fR()
  63. shall return
  64. 0.0, or
  65. (if the IEC 60559 Floating-Point option is not supported) an
  66. implementation-defined value no greater in magnitude than DBL_MIN,
  67. FLT_MIN, and LDBL_MIN, respectively.
  68. .P
  69. If
  70. .IR x
  71. is NaN, a NaN shall be returned.
  72. .P
  73. If
  74. .IR x
  75. is \(+-0, 1 shall be returned.
  76. .P
  77. If
  78. .IR x
  79. is \-Inf, +0 shall be returned.
  80. .P
  81. If
  82. .IR x
  83. is +Inf,
  84. .IR x
  85. shall be returned.
  86. .P
  87. If the correct value would cause underflow, and is representable, a
  88. range error may occur and the correct value shall be returned.
  89. .SH ERRORS
  90. These functions shall fail if:
  91. .IP "Range\ Error" 12
  92. The result overflows.
  93. .RS 12
  94. .P
  95. If the integer expression (\fImath_errhandling\fR & MATH_ERRNO) is
  96. non-zero, then
  97. .IR errno
  98. shall be set to
  99. .BR [ERANGE] .
  100. If the integer expression (\fImath_errhandling\fR & MATH_ERREXCEPT) is
  101. non-zero, then the overflow floating-point exception shall be raised.
  102. .RE
  103. .P
  104. These functions may fail if:
  105. .IP "Range\ Error" 12
  106. The result underflows.
  107. .RS 12
  108. .P
  109. If the integer expression (\fImath_errhandling\fR & MATH_ERRNO) is
  110. non-zero, then
  111. .IR errno
  112. shall be set to
  113. .BR [ERANGE] .
  114. If the integer expression (\fImath_errhandling\fR & MATH_ERREXCEPT) is
  115. non-zero, then the underflow floating-point exception shall be raised.
  116. .RE
  117. .LP
  118. .IR "The following sections are informative."
  119. .SH EXAMPLES
  120. .SS "Computing the Density of the Standard Normal Distribution"
  121. .P
  122. This function shows an implementation for the density of the standard
  123. normal distribution using
  124. \fIexp\fR().
  125. This example uses the constant M_PI which is part of the XSI option.
  126. .sp
  127. .RS 4
  128. .nf
  129. #include <math.h>
  130. .P
  131. double
  132. normal_density (double x)
  133. {
  134. return exp(-x*x/2) / sqrt (2*M_PI);
  135. }
  136. .fi
  137. .P
  138. .RE
  139. .SH "APPLICATION USAGE"
  140. On error, the expressions (\fImath_errhandling\fR & MATH_ERRNO) and
  141. (\fImath_errhandling\fR & MATH_ERREXCEPT) are independent of each
  142. other, but at least one of them must be non-zero.
  143. .SH RATIONALE
  144. None.
  145. .SH "FUTURE DIRECTIONS"
  146. None.
  147. .SH "SEE ALSO"
  148. .IR "\fIfeclearexcept\fR\^(\|)",
  149. .IR "\fIfetestexcept\fR\^(\|)",
  150. .IR "\fIisnan\fR\^(\|)",
  151. .IR "\fIlog\fR\^(\|)"
  152. .P
  153. The Base Definitions volume of POSIX.1\(hy2017,
  154. .IR "Section 4.20" ", " "Treatment of Error Conditions for Mathematical Functions",
  155. .IR "\fB<math.h>\fP"
  156. .\"
  157. .SH COPYRIGHT
  158. Portions of this text are reprinted and reproduced in electronic form
  159. from IEEE Std 1003.1-2017, Standard for Information Technology
  160. -- Portable Operating System Interface (POSIX), The Open Group Base
  161. Specifications Issue 7, 2018 Edition,
  162. Copyright (C) 2018 by the Institute of
  163. Electrical and Electronics Engineers, Inc and The Open Group.
  164. In the event of any discrepancy between this version and the original IEEE and
  165. The Open Group Standard, the original IEEE and The Open Group Standard
  166. is the referee document. The original Standard can be obtained online at
  167. http://www.opengroup.org/unix/online.html .
  168. .PP
  169. Any typographical or formatting errors that appear
  170. in this page are most likely
  171. to have been introduced during the conversion of the source files to
  172. man page format. To report such errors, see
  173. https://www.kernel.org/doc/man-pages/reporting_bugs.html .