DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

tgmath(5)


tgmath -- type generic math header file

Synopsis

   #include <tgmath.h>

Description

The header tgmath.h includes math(5) and defines several type-generic macros.

Of the math.h functions without an f (float) or l (long double) suffix, several have one or more parameters whose corresponding real type is double. For each such function, except modf, there is a corresponding type-generic macro. The parameters whose corresponding real type is double in the function synopsis are generic parameters. Use of the macro invokes a function whose corresponding real type and type domain are determined by the arguments for the generic parameters.


NOTE: Like other function-like macros in Standard libraries, each type-generic macro can be suppressed to make available the corresponding ordinary function.

Use of the macro invokes a function whose generic parameters have the corresponding real type, determined by the following rules:

  1. if any argument for generic parameters has type long double, the type determined is long double.

  2. if any argument for generic parameters has type double or is of integer type, the type determined is double.

  3. if the argument is not long double or double, its type is determined as float.


NOTE: If the type of the argument is not compatible with the type of the parameter for the selected function, the behavior is undefined.

For each unsuffixed function in math.h the corresponding type-generic macro has the same name as the function. These type-generic macros are shown below:

Type-generic macros in tgmath.h
acos acosh asin asinh
atan atanh atan2 cbrt
ceil copysign cos cosh
erf erfc exp exp2
expm1 fabs fdim floor
fma fmax fmin fmod
frexp hypot ilogb ldexp
lgamma llrint llround log
log10 log1p log2 logb
lrint lround nearbyint nextafter
nexttoward pow remainder remquo
rint round scalbn scalbln
sin sinh sqrt tan
tanh tgamma trunc  

 +----------------------------------------------+
 |       Type-generic macros in tgmath.h        |
 +-----------+----------+-----------+-----------+
 |acos       |  acosh   |   asin    |   asinh   |
 +-----------+----------+-----------+-----------+
 |atan       |  atanh   |   atan2   |   cbrt    |
 +-----------+----------+-----------+-----------+
 |ceil       | copysign |    cos    |   cosh    |
 +-----------+----------+-----------+-----------+
 |erf        |   erfc   |    exp    |   exp2    |
 +-----------+----------+-----------+-----------+
 |expm1      |   fabs   |   fdim    |   floor   |
 +-----------+----------+-----------+-----------+
 |fma        |   fmax   |   fmin    |   fmod    |
 +-----------+----------+-----------+-----------+
 |frexp      |  hypot   |   ilogb   |   ldexp   |
 +-----------+----------+-----------+-----------+
 |lgamma     |  llrint  |  llround  |    log    |
 +-----------+----------+-----------+-----------+
 |log10      |  log1p   |   log2    |   logb    |
 +-----------+----------+-----------+-----------+
 |lrint      |  lround  | nearbyint | nextafter |
 +-----------+----------+-----------+-----------+
 |nexttoward |   pow    | remainder |  remquo   |
 +-----------+----------+-----------+-----------+
 |rint       |  round   |  scalbn   |  scalbln  |
 +-----------+----------+-----------+-----------+
 |sin        |   sinh   |   sqrt    |    tan    |
 +-----------+----------+-----------+-----------+
 |tanh       |  tgamma  |   trunc   |           |
 +-----------+----------+-----------+-----------+
For example, using the following declarations:
   #include <tgmath.h>
   int n;
   float f;
   double d;
   long double ld;
the following functions are invoked by use of type-generic macros:

Macro Invokes
exp(n) exp(n), the function
acosh(f) acoshf(f)
sin(d) sin(d), the function
atan(ld) atanl(ld)
remainder(n, n) remainder(n, n), the function
nextafter(d, f) nextafter(d, f), the function
nexttoward(f, ld) nexttowardf(f, ld)
copysign(n, ld) copysignl(n, ld)

 +------------------+-------------------------------+
 |Macro             |            Invokes            |
 +------------------+-------------------------------+
 |exp(n)            |     exp(n), the function      |
 +------------------+-------------------------------+
 |acosh(f)          |           acoshf(f)           |
 +------------------+-------------------------------+
 |sin(d)            |     sin(d), the function      |
 +------------------+-------------------------------+
 |atan(ld)          |           atanl(ld)           |
 +------------------+-------------------------------+
 |remainder(n, n)   | remainder(n, n), the function |
 +------------------+-------------------------------+
 |nextafter(d, f)   | nextafter(d, f), the function |
 +------------------+-------------------------------+
 |nexttoward(f, ld) |      nexttowardf(f, ld)       |
 +------------------+-------------------------------+
 |copysign(n, ld)   |       copysignl(n, ld)        |
 +------------------+-------------------------------+

References

math(5), acos(3M), acosh(3M), asin(3M), asinh(3M), atan(3M), atanh(3M), atan2(3M), cbrt(3M), ceil(3M), copysign(3M), cos(3M), cosh(3M), erf(3M), erfc(3M), exp(3M), expm1(3M), fabs(3M), floor(3M), fmod(3M), hypot(3M), lgamma(3M), log(3M), log10(3M), log1p(3M), pow(3M), remainder(3M), rint(3M), sin(3M), sinh(3M), sqrt(3M), tan(3M), tanh(3M)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004