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

math.h.0p (16867B)


  1. '\" et
  2. .TH math.h "0P" 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. .EQ
  11. delim $$
  12. .EN
  13. .SH NAME
  14. math.h
  15. \(em mathematical declarations
  16. .SH SYNOPSIS
  17. .LP
  18. .nf
  19. #include <math.h>
  20. .fi
  21. .SH DESCRIPTION
  22. Some of the functionality described on this reference page extends the
  23. ISO\ C standard. Applications shall define the appropriate feature test macro
  24. (see the System Interfaces volume of POSIX.1\(hy2017,
  25. .IR "Section 2.2" ", " "The Compilation Environment")
  26. to enable the visibility of these symbols in this header.
  27. .P
  28. The
  29. .IR <math.h>
  30. header shall define at least the following types:
  31. .IP "\fBfloat_t\fR" 12
  32. A real-floating type at least as wide as
  33. .BR float .
  34. .IP "\fBdouble_t\fR" 12
  35. A real-floating type at least as wide as
  36. .BR double ,
  37. and at least as wide as
  38. .BR float_t .
  39. .P
  40. If FLT_EVAL_METHOD equals 0,
  41. .BR float_t
  42. and
  43. .BR double_t
  44. shall be
  45. .BR float
  46. and
  47. .BR double ,
  48. respectively; if FLT_EVAL_METHOD equals 1, they shall both be
  49. .BR double ;
  50. if FLT_EVAL_METHOD equals 2, they shall both be
  51. .BR "long double" ;
  52. for other values of FLT_EVAL_METHOD, they are otherwise
  53. implementation-defined.
  54. .P
  55. The
  56. .IR <math.h>
  57. header shall define the following macros, where real-floating indicates
  58. that the argument shall be an expression of real-floating type:
  59. .sp
  60. .RS 4
  61. .nf
  62. int fpclassify(real-floating x);
  63. int isfinite(real-floating x);
  64. int isgreater(real-floating x, real-floating y);
  65. int isgreaterequal(real-floating x, real-floating y);
  66. int isinf(real-floating x);
  67. int isless(real-floating x, real-floating y);
  68. int islessequal(real-floating x, real-floating y);
  69. int islessgreater(real-floating x, real-floating y);
  70. int isnan(real-floating x);
  71. int isnormal(real-floating x);
  72. int isunordered(real-floating x, real-floating y);
  73. int signbit(real-floating x);
  74. .fi
  75. .P
  76. .RE
  77. .P
  78. The
  79. .IR <math.h>
  80. header shall define the following symbolic constants. The values
  81. shall have type
  82. .BR double
  83. and shall be accurate to at least the precision of the
  84. .BR double
  85. type.
  86. .IP M_E 12
  87. Value of $e$
  88. .IP M_LOG2E 12
  89. Value of $log_ 2" " e$
  90. .IP M_LOG10E 12
  91. Value of $log_ 10" " e$
  92. .IP M_LN2 12
  93. Value of $log_ e" " 2$
  94. .IP M_LN10 12
  95. Value of $log_ e" " 10$
  96. .IP M_PI 12
  97. Value of $pi$
  98. .IP M_PI_2 12
  99. Value of $pi /2$
  100. .IP M_PI_4 12
  101. Value of $pi /4$
  102. .IP M_1_PI 12
  103. Value of $1/ pi$
  104. .IP M_2_PI 12
  105. Value of $2/ pi$
  106. .IP M_2_SQRTPI 12
  107. Value of $2/ sqrt pi$
  108. .IP M_SQRT2 12
  109. Value of $sqrt 2$
  110. .IP M_SQRT1_2 12
  111. Value of $1/ sqrt 2$
  112. .P
  113. The
  114. .IR <math.h>
  115. header shall define the following symbolic constant:
  116. .IP MAXFLOAT 12
  117. Same value as FLT_MAX in
  118. .IR <float.h> .
  119. .P
  120. The
  121. .IR <math.h>
  122. header shall define the following macros:
  123. .IP HUGE_VAL 12
  124. A positive
  125. .BR double
  126. constant expression, not necessarily representable as a
  127. .BR float .
  128. Used as an error value returned by the mathematics library. HUGE_VAL
  129. evaluates to +infinity on systems supporting IEEE\ Std\ 754\(hy1985.
  130. .IP HUGE_VALF 12
  131. A positive
  132. .BR float
  133. constant expression. Used as an error value returned by the mathematics
  134. library. HUGE_VALF evaluates to +infinity on systems supporting IEEE\ Std\ 754\(hy1985.
  135. .IP HUGE_VALL 12
  136. A positive
  137. .BR "long double"
  138. constant expression. Used as an error value returned by the mathematics
  139. library. HUGE_VALL evaluates to +infinity on systems supporting IEEE\ Std\ 754\(hy1985.
  140. .IP INFINITY 12
  141. A constant expression of type
  142. .BR float
  143. representing positive or unsigned infinity, if available; else a
  144. positive constant of type
  145. .BR float
  146. that overflows at translation time.
  147. .IP NAN 12
  148. A constant expression of type
  149. .BR float
  150. representing a quiet NaN. This macro is only defined if the
  151. implementation supports quiet NaNs for the
  152. .BR float
  153. type.
  154. .P
  155. The following macros shall be defined for number classification. They
  156. represent the mutually-exclusive kinds of floating-point values. They
  157. expand to integer constant expressions with distinct values. Additional
  158. implementation-defined floating-point classifications, with macro
  159. definitions beginning with FP_ and an uppercase letter, may also be
  160. specified by the implementation.
  161. .sp
  162. .RS
  163. FP_INFINITE
  164. FP_NAN
  165. FP_NORMAL
  166. FP_SUBNORMAL
  167. FP_ZERO
  168. .RE
  169. .P
  170. The following optional macros indicate whether the
  171. \fIfma\fR()
  172. family of functions are fast compared with direct code:
  173. .sp
  174. .RS
  175. FP_FAST_FMA
  176. FP_FAST_FMAF
  177. FP_FAST_FMAL
  178. .RE
  179. .P
  180. If defined, the FP_FAST_FMA macro shall expand to the integer constant
  181. 1 and shall indicate that the
  182. \fIfma\fR()
  183. function generally executes about as fast as, or faster than, a
  184. multiply and an add of
  185. .BR double
  186. operands. If undefined, the speed of execution is unspecified. The
  187. other macros have the equivalent meaning for the
  188. .BR float
  189. and
  190. .BR "long double"
  191. versions.
  192. .P
  193. The following macros shall expand to integer constant expressions whose
  194. values are returned by
  195. .IR ilogb (\c
  196. .IR x )
  197. if
  198. .IR x
  199. is zero or NaN, respectively. The value of FP_ILOGB0 shall be either
  200. {INT_MIN}
  201. or \-\c
  202. {INT_MAX}.
  203. The value of FP_ILOGBNAN shall be either
  204. {INT_MAX}
  205. or
  206. {INT_MIN}.
  207. .sp
  208. .RS
  209. FP_ILOGB0
  210. FP_ILOGBNAN
  211. .RE
  212. .P
  213. The following macros shall expand to the integer constants 1 and 2,
  214. respectively;
  215. .sp
  216. .RS
  217. MATH_ERRNO
  218. MATH_ERREXCEPT
  219. .RE
  220. .P
  221. The following macro shall expand to an expression that has type
  222. .BR int
  223. and the value MATH_ERRNO, MATH_ERREXCEPT, or the bitwise-inclusive OR
  224. of both:
  225. .sp
  226. .RS
  227. math_errhandling
  228. .RE
  229. .P
  230. The value of math_errhandling is constant for the duration of the
  231. program. It is unspecified whether math_errhandling is a macro or an
  232. identifier with external linkage. If a macro definition is suppressed
  233. or a program defines an identifier with the name math_errhandling , the
  234. behavior is undefined. If the expression (math_errhandling &
  235. MATH_ERREXCEPT) can be non-zero, the implementation shall define the
  236. macros FE_DIVBYZERO, FE_INVALID, and FE_OVERFLOW in
  237. .IR <fenv.h> .
  238. .P
  239. The following shall be declared as functions and may also be defined as
  240. macros. Function prototypes shall be provided.
  241. .sp
  242. .RS 4
  243. .nf
  244. double acos(double);
  245. float acosf(float);
  246. double acosh(double);
  247. float acoshf(float);
  248. long double acoshl(long double);
  249. long double acosl(long double);
  250. double asin(double);
  251. float asinf(float);
  252. double asinh(double);
  253. float asinhf(float);
  254. long double asinhl(long double);
  255. long double asinl(long double);
  256. double atan(double);
  257. double atan2(double, double);
  258. float atan2f(float, float);
  259. long double atan2l(long double, long double);
  260. float atanf(float);
  261. double atanh(double);
  262. float atanhf(float);
  263. long double atanhl(long double);
  264. long double atanl(long double);
  265. double cbrt(double);
  266. float cbrtf(float);
  267. long double cbrtl(long double);
  268. double ceil(double);
  269. float ceilf(float);
  270. long double ceill(long double);
  271. double copysign(double, double);
  272. float copysignf(float, float);
  273. long double copysignl(long double, long double);
  274. double cos(double);
  275. float cosf(float);
  276. double cosh(double);
  277. float coshf(float);
  278. long double coshl(long double);
  279. long double cosl(long double);
  280. double erf(double);
  281. double erfc(double);
  282. float erfcf(float);
  283. long double erfcl(long double);
  284. float erff(float);
  285. long double erfl(long double);
  286. double exp(double);
  287. double exp2(double);
  288. float exp2f(float);
  289. long double exp2l(long double);
  290. float expf(float);
  291. long double expl(long double);
  292. double expm1(double);
  293. float expm1f(float);
  294. long double expm1l(long double);
  295. double fabs(double);
  296. float fabsf(float);
  297. long double fabsl(long double);
  298. double fdim(double, double);
  299. float fdimf(float, float);
  300. long double fdiml(long double, long double);
  301. double floor(double);
  302. float floorf(float);
  303. long double floorl(long double);
  304. double fma(double, double, double);
  305. float fmaf(float, float, float);
  306. long double fmal(long double, long double, long double);
  307. double fmax(double, double);
  308. float fmaxf(float, float);
  309. long double fmaxl(long double, long double);
  310. double fmin(double, double);
  311. float fminf(float, float);
  312. long double fminl(long double, long double);
  313. double fmod(double, double);
  314. float fmodf(float, float);
  315. long double fmodl(long double, long double);
  316. double frexp(double, int *);
  317. float frexpf(float, int *);
  318. long double frexpl(long double, int *);
  319. double hypot(double, double);
  320. float hypotf(float, float);
  321. long double hypotl(long double, long double);
  322. int ilogb(double);
  323. int ilogbf(float);
  324. int ilogbl(long double);
  325. double j0(double);
  326. double j1(double);
  327. double jn(int, double);
  328. double ldexp(double, int);
  329. float ldexpf(float, int);
  330. long double ldexpl(long double, int);
  331. double lgamma(double);
  332. float lgammaf(float);
  333. long double lgammal(long double);
  334. long long llrint(double);
  335. long long llrintf(float);
  336. long long llrintl(long double);
  337. long long llround(double);
  338. long long llroundf(float);
  339. long long llroundl(long double);
  340. double log(double);
  341. double log10(double);
  342. float log10f(float);
  343. long double log10l(long double);
  344. double log1p(double);
  345. float log1pf(float);
  346. long double log1pl(long double);
  347. double log2(double);
  348. float log2f(float);
  349. long double log2l(long double);
  350. double logb(double);
  351. float logbf(float);
  352. long double logbl(long double);
  353. float logf(float);
  354. long double logl(long double);
  355. long lrint(double);
  356. long lrintf(float);
  357. long lrintl(long double);
  358. long lround(double);
  359. long lroundf(float);
  360. long lroundl(long double);
  361. double modf(double, double *);
  362. float modff(float, float *);
  363. long double modfl(long double, long double *);
  364. double nan(const char *);
  365. float nanf(const char *);
  366. long double nanl(const char *);
  367. double nearbyint(double);
  368. float nearbyintf(float);
  369. long double nearbyintl(long double);
  370. double nextafter(double, double);
  371. float nextafterf(float, float);
  372. long double nextafterl(long double, long double);
  373. double nexttoward(double, long double);
  374. float nexttowardf(float, long double);
  375. long double nexttowardl(long double, long double);
  376. double pow(double, double);
  377. float powf(float, float);
  378. long double powl(long double, long double);
  379. double remainder(double, double);
  380. float remainderf(float, float);
  381. long double remainderl(long double, long double);
  382. double remquo(double, double, int *);
  383. float remquof(float, float, int *);
  384. long double remquol(long double, long double, int *);
  385. double rint(double);
  386. float rintf(float);
  387. long double rintl(long double);
  388. double round(double);
  389. float roundf(float);
  390. long double roundl(long double);
  391. double scalbln(double, long);
  392. float scalblnf(float, long);
  393. long double scalblnl(long double, long);
  394. double scalbn(double, int);
  395. float scalbnf(float, int);
  396. long double scalbnl(long double, int);
  397. double sin(double);
  398. float sinf(float);
  399. double sinh(double);
  400. float sinhf(float);
  401. long double sinhl(long double);
  402. long double sinl(long double);
  403. double sqrt(double);
  404. float sqrtf(float);
  405. long double sqrtl(long double);
  406. double tan(double);
  407. float tanf(float);
  408. double tanh(double);
  409. float tanhf(float);
  410. long double tanhl(long double);
  411. long double tanl(long double);
  412. double tgamma(double);
  413. float tgammaf(float);
  414. long double tgammal(long double);
  415. double trunc(double);
  416. float truncf(float);
  417. long double truncl(long double);
  418. double y0(double);
  419. double y1(double);
  420. double yn(int, double);
  421. .fi
  422. .P
  423. .RE
  424. .P
  425. The following external variable shall be defined:
  426. .sp
  427. .RS 4
  428. .nf
  429. extern int signgam;
  430. .fi
  431. .P
  432. .RE
  433. .P
  434. The behavior of each of the functions defined in
  435. .IR <math.h>
  436. is specified in the System Interfaces volume of POSIX.1\(hy2017 for all representable values of its input
  437. arguments, except where stated otherwise. Each function shall execute
  438. as if it were a single operation without generating any externally
  439. visible exceptional conditions.
  440. .LP
  441. .IR "The following sections are informative."
  442. .SH "APPLICATION USAGE"
  443. The FP_CONTRACT pragma can be used to allow (if the state is on) or
  444. disallow (if the state is off) the implementation to contract
  445. expressions. Each pragma can occur either outside external declarations
  446. or preceding all explicit declarations and statements inside a compound
  447. statement. When outside external declarations, the pragma takes effect
  448. from its occurrence until another FP_CONTRACT pragma is encountered, or
  449. until the end of the translation unit. When inside a compound
  450. statement, the pragma takes effect from its occurrence until another
  451. FP_CONTRACT pragma is encountered (including within a nested compound
  452. statement), or until the end of the compound statement; at the end of a
  453. compound statement the state for the pragma is restored to its
  454. condition just before the compound statement. If this pragma is used in
  455. any other context, the behavior is undefined. The default state (on or
  456. off) for the pragma is implementation-defined.
  457. .P
  458. Applications should use FLT_MAX as described in the
  459. .IR <float.h>
  460. header instead of the obsolescent MAXFLOAT.
  461. .P
  462. Note that if FLT_EVAL_METHOD is neither 0 nor 1, then some constants might
  463. not compare equal as expected; for example, \fR(double)M_PI == M_PI\fR
  464. can fail.
  465. .SH RATIONALE
  466. Before the ISO/IEC\ 9899:\|1999 standard, the math library was defined only for the floating
  467. type
  468. .BR double .
  469. All the names formed by appending
  470. .BR 'f'
  471. or
  472. .BR 'l'
  473. to a name in
  474. .IR <math.h>
  475. were reserved to allow for the definition of
  476. .BR float
  477. and
  478. .BR "long double"
  479. libraries; and the ISO/IEC\ 9899:\|1999 standard provides for all three versions of math
  480. functions.
  481. .P
  482. The functions
  483. .IR ecvt (\|),
  484. .IR fcvt (\|),
  485. and
  486. .IR gcvt (\|)
  487. have been dropped from the ISO\ C standard since their capability is available
  488. through
  489. \fIsprintf\fR().
  490. .SH "FUTURE DIRECTIONS"
  491. None.
  492. .SH "SEE ALSO"
  493. .IR "\fB<float.h>\fP",
  494. .IR "\fB<stddef.h>\fP",
  495. .IR "\fB<sys_types.h>\fP"
  496. .P
  497. The System Interfaces volume of POSIX.1\(hy2017,
  498. .IR "Section 2.2" ", " "The Compilation Environment",
  499. .IR "\fIacos\fR\^(\|)",
  500. .IR "\fIacosh\fR\^(\|)",
  501. .IR "\fIasin\fR\^(\|)",
  502. .IR "\fIasinh\fR\^(\|)",
  503. .IR "\fIatan\fR\^(\|)",
  504. .IR "\fIatan2\fR\^(\|)",
  505. .IR "\fIatanh\fR\^(\|)",
  506. .IR "\fIcbrt\fR\^(\|)",
  507. .IR "\fIceil\fR\^(\|)",
  508. .IR "\fIcopysign\fR\^(\|)",
  509. .IR "\fIcos\fR\^(\|)",
  510. .IR "\fIcosh\fR\^(\|)",
  511. .IR "\fIerf\fR\^(\|)",
  512. .IR "\fIerfc\fR\^(\|)",
  513. .IR "\fIexp\fR\^(\|)",
  514. .IR "\fIexp2\fR\^(\|)",
  515. .IR "\fIexpm1\fR\^(\|)",
  516. .IR "\fIfabs\fR\^(\|)",
  517. .IR "\fIfdim\fR\^(\|)",
  518. .IR "\fIfloor\fR\^(\|)",
  519. .IR "\fIfma\fR\^(\|)",
  520. .IR "\fIfmax\fR\^(\|)",
  521. .IR "\fIfmin\fR\^(\|)",
  522. .IR "\fIfmod\fR\^(\|)",
  523. .IR "\fIfpclassify\fR\^(\|)",
  524. .IR "\fIfrexp\fR\^(\|)",
  525. .IR "\fIhypot\fR\^(\|)",
  526. .IR "\fIilogb\fR\^(\|)",
  527. .IR "\fIisfinite\fR\^(\|)",
  528. .IR "\fIisgreater\fR\^(\|)",
  529. .IR "\fIisgreaterequal\fR\^(\|)",
  530. .IR "\fIisinf\fR\^(\|)",
  531. .IR "\fIisless\fR\^(\|)",
  532. .IR "\fIislessequal\fR\^(\|)",
  533. .IR "\fIislessgreater\fR\^(\|)",
  534. .IR "\fIisnan\fR\^(\|)",
  535. .IR "\fIisnormal\fR\^(\|)",
  536. .IR "\fIisunordered\fR\^(\|)",
  537. .IR "\fIj0\fR\^(\|)",
  538. .IR "\fIldexp\fR\^(\|)",
  539. .IR "\fIlgamma\fR\^(\|)",
  540. .IR "\fIllrint\fR\^(\|)",
  541. .IR "\fIllround\fR\^(\|)",
  542. .IR "\fIlog\fR\^(\|)",
  543. .IR "\fIlog10\fR\^(\|)",
  544. .IR "\fIlog1p\fR\^(\|)",
  545. .IR "\fIlog2\fR\^(\|)",
  546. .IR "\fIlogb\fR\^(\|)",
  547. .IR "\fIlrint\fR\^(\|)",
  548. .IR "\fIlround\fR\^(\|)",
  549. .IR "\fImodf\fR\^(\|)",
  550. .IR "\fInan\fR\^(\|)",
  551. .IR "\fInearbyint\fR\^(\|)",
  552. .IR "\fInextafter\fR\^(\|)",
  553. .IR "\fIpow\fR\^(\|)",
  554. .IR "\fIremainder\fR\^(\|)",
  555. .IR "\fIremquo\fR\^(\|)",
  556. .IR "\fIrint\fR\^(\|)",
  557. .IR "\fIround\fR\^(\|)",
  558. .IR "\fIscalbln\fR\^(\|)",
  559. .IR "\fIsignbit\fR\^(\|)",
  560. .IR "\fIsin\fR\^(\|)",
  561. .IR "\fIsinh\fR\^(\|)",
  562. .IR "\fIsqrt\fR\^(\|)",
  563. .IR "\fItan\fR\^(\|)",
  564. .IR "\fItanh\fR\^(\|)",
  565. .IR "\fItgamma\fR\^(\|)",
  566. .IR "\fItrunc\fR\^(\|)",
  567. .IR "\fIy0\fR\^(\|)"
  568. .\"
  569. .SH COPYRIGHT
  570. Portions of this text are reprinted and reproduced in electronic form
  571. from IEEE Std 1003.1-2017, Standard for Information Technology
  572. -- Portable Operating System Interface (POSIX), The Open Group Base
  573. Specifications Issue 7, 2018 Edition,
  574. Copyright (C) 2018 by the Institute of
  575. Electrical and Electronics Engineers, Inc and The Open Group.
  576. In the event of any discrepancy between this version and the original IEEE and
  577. The Open Group Standard, the original IEEE and The Open Group Standard
  578. is the referee document. The original Standard can be obtained online at
  579. http://www.opengroup.org/unix/online.html .
  580. .PP
  581. Any typographical or formatting errors that appear
  582. in this page are most likely
  583. to have been introduced during the conversion of the source files to
  584. man page format. To report such errors, see
  585. https://www.kernel.org/doc/man-pages/reporting_bugs.html .