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

NAME

6       math.h - mathematical declarations
7

SYNOPSIS

9       #include <math.h>
10

DESCRIPTION

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

APPLICATION USAGE

383       The  FP_CONTRACT  pragma  can  be used to allow (if the state is on) or
384       disallow (if the state is off) the implementation to  contract  expres‐
385       sions.  Each  pragma  can occur either outside external declarations or
386       preceding all explicit declarations and statements  inside  a  compound
387       statement.  When outside external declarations, the pragma takes effect
388       from its occurrence until another FP_CONTRACT pragma is encountered, or
389       until  the  end  of the translation unit. When inside a compound state‐
390       ment, the pragma takes effect from its occurrence until another FP_CON‐
391       TRACT  pragma is encountered (including within a nested compound state‐
392       ment), or until the end of the compound statement; at the end of a com‐
393       pound  statement  the state for the pragma is restored to its condition
394       just before the compound statement. If this pragma is used in any other
395       context,  the  behavior is undefined. The default state (on or off) for
396       the pragma is implementation-defined.
397

RATIONALE

399       Before the ISO/IEC 9899:1999 standard, the  math  library  was  defined
400       only  for  the  floating type double. All the names formed by appending
401       'f' or 'l' to a name in <math.h> were reserved to allow for the defini‐
402       tion  of  float  and  long  double libraries; and the ISO/IEC 9899:1999
403       standard provides for all three versions of math functions.
404
405       The functions ecvt(), fcvt(), and gcvt() have  been  dropped  from  the
406       ISO C  standard  since their capability is available through sprintf().
407       These are provided on  XSI-conformant  systems  supporting  the  Legacy
408       Option Group.
409

FUTURE DIRECTIONS

411       None.
412

SEE ALSO

414       <stddef.h>,    <sys/types.h>,   the   System   Interfaces   volume   of
415       IEEE Std 1003.1-2001, acos(), acosh(), asin(), atan(), atan2(), cbrt(),
416       ceil(),  cos(), cosh(), erf(), exp(), expm1(), fabs(), floor(), fmod(),
417       frexp(), hypot(), ilogb(), isnan(),  j0(),  ldexp(),  lgamma(),  log(),
418       log10(),  log1p(),  logb(),  modf(),  nextafter(),  pow(), remainder(),
419       rint(), scalb(), sin(), sinh(), sqrt(), tan(), tanh(), y0()
420
422       Portions of this text are reprinted and reproduced in  electronic  form
423       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
424       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
425       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
426       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
427       event of any discrepancy between this version and the original IEEE and
428       The Open Group Standard, the original IEEE and The Open Group  Standard
429       is  the  referee document. The original Standard can be obtained online
430       at http://www.opengroup.org/unix/online.html .
431
432
433
434IEEE/The Open Group                  2003                         <math.h>(0P)
Impressum