1math.h(0P)                 POSIX Programmer's Manual                math.h(0P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       math.h — mathematical declarations
14

SYNOPSIS

16       #include <math.h>
17

DESCRIPTION

19       Some of the functionality described on this reference page extends  the
20       ISO C  standard. Applications shall define the appropriate feature test
21       macro (see the System Interfaces volume of POSIX.1‐2008,  Section  2.2,
22       The  Compilation Environment) to enable the visibility of these symbols
23       in this header.
24
25       The <math.h> header shall define at least the following types:
26
27       float_t     A real-floating type at least as wide as float.
28
29       double_t    A real-floating type at least as wide  as  double,  and  at
30                   least as wide as float_t.
31
32       If  FLT_EVAL_METHOD  equals  0, float_t and double_t shall be float and
33       double, respectively; if FLT_EVAL_METHOD equals 1, they shall  both  be
34       double;  if  FLT_EVAL_METHOD  equals 2, they shall both be long double;
35       for other values of FLT_EVAL_METHOD, they are otherwise implementation-
36       defined.
37
38       The  <math.h>  header  shall  define  the following macros, where real-
39       floating indicates that the argument shall be an  expression  of  real-
40       floating type:
41
42           int fpclassify(real-floating x);
43           int isfinite(real-floating x);
44           int isgreater(real-floating x, real-floating y);
45           int isgreaterequal(real-floating x, real-floating y);
46           int isinf(real-floating x);
47           int isless(real-floating x, real-floating y);
48           int islessequal(real-floating x, real-floating y);
49           int islessgreater(real-floating x, real-floating y);
50           int isnan(real-floating x);
51           int isnormal(real-floating x);
52           int isunordered(real-floating x, real-floating y);
53           int signbit(real-floating x);
54
55       The  <math.h> header shall define the following symbolic constants. The
56       values shall have type double and shall be accurate within  the  preci‐
57       sion of the double type.
58
59       M_E         Value of e
60
61       M_LOG2E     Value of log_2 e
62
63       M_LOG10E    Value of log_10 e
64
65       M_LN2       Value of log_e 2
66
67       M_LN10      Value of log_e 10
68
69       M_PI        Value of π
70
71       M_PI_2      Value of π/2
72
73       M_PI_4      Value of π/4
74
75       M_1_PI      Value of 1/π
76
77       M_2_PI      Value of 2/π
78
79       M_2_SQRTPI  Value of 2/π
80
81       M_SQRT2     Value of 2
82
83       M_SQRT1_2   Value of 1/2
84
85       The <math.h> header shall define the following symbolic constant:
86
87       MAXFLOAT    Same value as FLT_MAX in <float.h>.
88
89       The <math.h> header shall define the following macros:
90
91       HUGE_VAL    A positive double constant expression, not necessarily rep‐
92                   resentable as a float.  Used as an error value returned  by
93                   the mathematics library. HUGE_VAL evaluates to +infinity on
94                   systems supporting IEEE Std 754‐1985.
95
96       HUGE_VALF   A positive float constant  expression.  Used  as  an  error
97                   value returned by the mathematics library. HUGE_VALF evalu‐
98                   ates to +infinity on systems supporting IEEE Std 754‐1985.
99
100       HUGE_VALL   A positive long double  constant  expression.  Used  as  an
101                   error  value returned by the mathematics library. HUGE_VALL
102                   evaluates    to    +infinity    on    systems    supporting
103                   IEEE Std 754‐1985.
104
105       INFINITY    A  constant  expression of type float representing positive
106                   or unsigned infinity, if available; else  a  positive  con‐
107                   stant of type float that overflows at translation time.
108
109       NAN         A  constant  expression  of type float representing a quiet
110                   NaN. This macro is only defined if the implementation  sup‐
111                   ports quiet NaNs for the float type.
112
113       The  following  macros shall be defined for number classification. They
114       represent the mutually-exclusive kinds of floating-point  values.  They
115       expand to integer constant expressions with distinct values. Additional
116       implementation-defined floating-point classifications, with macro defi‐
117       nitions  beginning with FP_ and an uppercase letter, may also be speci‐
118       fied by the implementation.
119
120              FP_INFINITE FP_NAN FP_NORMAL FP_SUBNORMAL FP_ZERO
121
122       The following optional macros indicate  whether  the  fma()  family  of
123       functions are fast compared with direct code:
124
125              FP_FAST_FMA FP_FAST_FMAF FP_FAST_FMAL
126
127       If  defined, the FP_FAST_FMA macro shall expand to the integer constant
128       1 and shall indicate that the fma() function generally  executes  about
129       as  fast  as, or faster than, a multiply and an add of double operands.
130       If undefined, the speed of execution is unspecified. The  other  macros
131       have the equivalent meaning for the float and long double versions.
132
133       The following macros shall expand to integer constant expressions whose
134       values are returned by ilogb(x) if x is zero or NaN, respectively.  The
135       value  of FP_ILOGB0 shall be either {INT_MIN} or −{INT_MAX}.  The value
136       of FP_ILOGBNAN shall be either {INT_MAX} or {INT_MIN}.
137
138              FP_ILOGB0 FP_ILOGBNAN
139
140       The following macros shall expand to the integer  constants  1  and  2,
141       respectively;
142
143              MATH_ERRNO MATH_ERREXCEPT
144
145       The following macro shall expand to an expression that has type int and
146       the value MATH_ERRNO, MATH_ERREXCEPT, or the  bitwise-inclusive  OR  of
147       both:
148
149              math_errhandling
150
151       The  value of math_errhandling is constant for the duration of the pro‐
152       gram. It is unspecified whether math_errhandling is a macro or an iden‐
153       tifier  with external linkage. If a macro definition is suppressed or a
154       program defines an identifier with  the  name  math_errhandling  ,  the
155       behavior   is   undefined.   If   the  expression  (math_errhandling  &
156       MATH_ERREXCEPT) can be non-zero, the implementation  shall  define  the
157       macros FE_DIVBYZERO, FE_INVALID, and FE_OVERFLOW in <fenv.h>.
158
159       The following shall be declared as functions and may also be defined as
160       macros. Function prototypes shall be provided.
161
162           double      acos(double);
163           float       acosf(float);
164           double      acosh(double);
165           float       acoshf(float);
166           long double acoshl(long double);
167           long double acosl(long double);
168           double      asin(double);
169           float       asinf(float);
170           double      asinh(double);
171           float       asinhf(float);
172           long double asinhl(long double);
173           long double asinl(long double);
174           double      atan(double);
175           double      atan2(double, double);
176           float       atan2f(float, float);
177           long double atan2l(long double, long double);
178           float       atanf(float);
179           double      atanh(double);
180           float       atanhf(float);
181           long double atanhl(long double);
182           long double atanl(long double);
183           double      cbrt(double);
184           float       cbrtf(float);
185           long double cbrtl(long double);
186           double      ceil(double);
187           float       ceilf(float);
188           long double ceill(long double);
189           double      copysign(double, double);
190           float       copysignf(float, float);
191           long double copysignl(long double, long double);
192           double      cos(double);
193           float       cosf(float);
194           double      cosh(double);
195           float       coshf(float);
196           long double coshl(long double);
197           long double cosl(long double);
198           double      erf(double);
199           double      erfc(double);
200           float       erfcf(float);
201           long double erfcl(long double);
202           float       erff(float);
203           long double erfl(long double);
204           double      exp(double);
205           double      exp2(double);
206           float       exp2f(float);
207           long double exp2l(long double);
208           float       expf(float);
209           long double expl(long double);
210           double      expm1(double);
211           float       expm1f(float);
212           long double expm1l(long double);
213           double      fabs(double);
214           float       fabsf(float);
215           long double fabsl(long double);
216           double      fdim(double, double);
217           float       fdimf(float, float);
218           long double fdiml(long double, long double);
219           double      floor(double);
220           float       floorf(float);
221           long double floorl(long double);
222           double      fma(double, double, double);
223           float       fmaf(float, float, float);
224           long double fmal(long double, long double, long double);
225           double      fmax(double, double);
226           float       fmaxf(float, float);
227           long double fmaxl(long double, long double);
228           double      fmin(double, double);
229           float       fminf(float, float);
230           long double fminl(long double, long double);
231           double      fmod(double, double);
232           float       fmodf(float, float);
233           long double fmodl(long double, long double);
234           double      frexp(double, int *);
235           float       frexpf(float, int *);
236           long double frexpl(long double, int *);
237           double      hypot(double, double);
238           float       hypotf(float, float);
239           long double hypotl(long double, long double);
240           int         ilogb(double);
241           int         ilogbf(float);
242           int         ilogbl(long double);
243           double      j0(double);
244           double      j1(double);
245           double      jn(int, double);
246           double      ldexp(double, int);
247           float       ldexpf(float, int);
248           long double ldexpl(long double, int);
249           double      lgamma(double);
250           float       lgammaf(float);
251           long double lgammal(long double);
252           long long   llrint(double);
253           long long   llrintf(float);
254           long long   llrintl(long double);
255           long long   llround(double);
256           long long   llroundf(float);
257           long long   llroundl(long double);
258           double      log(double);
259           double      log10(double);
260           float       log10f(float);
261           long double log10l(long double);
262           double      log1p(double);
263           float       log1pf(float);
264           long double log1pl(long double);
265           double      log2(double);
266           float       log2f(float);
267           long double log2l(long double);
268           double      logb(double);
269           float       logbf(float);
270           long double logbl(long double);
271           float       logf(float);
272           long double logl(long double);
273           long        lrint(double);
274           long        lrintf(float);
275           long        lrintl(long double);
276           long        lround(double);
277           long        lroundf(float);
278           long        lroundl(long double);
279           double      modf(double, double *);
280           float       modff(float, float *);
281           long double modfl(long double, long double *);
282           double      nan(const char *);
283           float       nanf(const char *);
284           long double nanl(const char *);
285           double      nearbyint(double);
286           float       nearbyintf(float);
287           long double nearbyintl(long double);
288           double      nextafter(double, double);
289           float       nextafterf(float, float);
290           long double nextafterl(long double, long double);
291           double      nexttoward(double, long double);
292           float       nexttowardf(float, long double);
293           long double nexttowardl(long double, long double);
294           double      pow(double, double);
295           float       powf(float, float);
296           long double powl(long double, long double);
297           double      remainder(double, double);
298           float       remainderf(float, float);
299           long double remainderl(long double, long double);
300           double      remquo(double, double, int *);
301           float       remquof(float, float, int *);
302           long double remquol(long double, long double, int *);
303           double      rint(double);
304           float       rintf(float);
305           long double rintl(long double);
306           double      round(double);
307           float       roundf(float);
308           long double roundl(long double);
309           double      scalbln(double, long);
310           float       scalblnf(float, long);
311           long double scalblnl(long double, long);
312           double      scalbn(double, int);
313           float       scalbnf(float, int);
314           long double scalbnl(long double, int);
315           double      sin(double);
316           float       sinf(float);
317           double      sinh(double);
318           float       sinhf(float);
319           long double sinhl(long double);
320           long double sinl(long double);
321           double      sqrt(double);
322           float       sqrtf(float);
323           long double sqrtl(long double);
324           double      tan(double);
325           float       tanf(float);
326           double      tanh(double);
327           float       tanhf(float);
328           long double tanhl(long double);
329           long double tanl(long double);
330           double      tgamma(double);
331           float       tgammaf(float);
332           long double tgammal(long double);
333           double      trunc(double);
334           float       truncf(float);
335           long double truncl(long double);
336           double      y0(double);
337           double      y1(double);
338           double      yn(int, double);
339
340       The following external variable shall be defined:
341
342           extern int signgam;
343
344       The behavior of each of the functions defined in <math.h> is  specified
345       in  the  System Interfaces volume of POSIX.1‐2008 for all representable
346       values of its input arguments,  except  where  stated  otherwise.  Each
347       function  shall execute as if it were a single operation without gener‐
348       ating any externally visible exceptional conditions.
349
350       The following sections are informative.
351

APPLICATION USAGE

353       The FP_CONTRACT pragma can be used to allow (if the  state  is  on)  or
354       disallow  (if  the state is off) the implementation to contract expres‐
355       sions. Each pragma can occur either outside  external  declarations  or
356       preceding  all  explicit  declarations and statements inside a compound
357       statement. When outside external declarations, the pragma takes  effect
358       from its occurrence until another FP_CONTRACT pragma is encountered, or
359       until the end of the translation unit. When inside  a  compound  state‐
360       ment, the pragma takes effect from its occurrence until another FP_CON‐
361       TRACT pragma is encountered (including within a nested compound  state‐
362       ment), or until the end of the compound statement; at the end of a com‐
363       pound statement the state for the pragma is restored to  its  condition
364       just before the compound statement. If this pragma is used in any other
365       context, the behavior is undefined. The default state (on or  off)  for
366       the pragma is implementation-defined.
367
368       Applications  should  use  FLT_MAX as described in the <float.h> header
369       instead of the obsolescent MAXFLOAT.
370

RATIONALE

372       Before the ISO/IEC 9899:1999 standard, the  math  library  was  defined
373       only  for  the floating type double.  All the names formed by appending
374       'f' or 'l' to a name in <math.h> were reserved to allow for the defini‐
375       tion  of  float  and  long  double libraries; and the ISO/IEC 9899:1999
376       standard provides for all three versions of math functions.
377
378       The functions ecvt(), fcvt(), and gcvt() have  been  dropped  from  the
379       ISO C standard since their capability is available through sprintf().
380

FUTURE DIRECTIONS

382       None.
383

SEE ALSO

385       <float.h>, <stddef.h>, <sys_types.h>
386
387       The System Interfaces volume of POSIX.1‐2008, Section 2.2, The Compila‐
388       tion Environment, acos(), acosh(), asin(),  asinh(),  atan(),  atan2(),
389       atanh(),  cbrt(),  ceil(),  copysign(),  cos(),  cosh(), erf(), erfc(),
390       exp(), exp2(), expm1(), fabs(), fdim(), floor(), fma(), fmax(), fmin(),
391       fmod(),    fpclassify(),   frexp(),   hypot(),   ilogb(),   isfinite(),
392       isgreater(),  isgreaterequal(),   isinf(),   isless(),   islessequal(),
393       islessgreater(),  isnan(),  isnormal(),  isunordered(),  j0(), ldexp(),
394       lgamma(), llrint(), llround(), log(), log10(), log1p(), log2(), logb(),
395       lrint(),  lround(),  modf(),  nan(),  nearbyint(),  nextafter(), pow(),
396       remainder(), remquo(), rint(), round(),  scalbln(),  signbit(),  sin(),
397       sinh(), sqrt(), tan(), tanh(), tgamma(), trunc(), y0()
398
400       Portions  of  this text are reprinted and reproduced in electronic form
401       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
402       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
403       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
404       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
405       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
406       event of any discrepancy between this version and the original IEEE and
407       The Open Group Standard, the original IEEE and The Open Group  Standard
408       is  the  referee document. The original Standard can be obtained online
409       at http://www.unix.org/online.html .
410
411       Any typographical or formatting errors that appear  in  this  page  are
412       most likely to have been introduced during the conversion of the source
413       files to man page format. To report such errors,  see  https://www.ker
414       nel.org/doc/man-pages/reporting_bugs.html .
415
416
417
418IEEE/The Open Group                  2013                           math.h(0P)
Impressum