Type-generic macros for invoking functions declared in math.h and complex.h.
The math.h and complex.h header files declare many functions in variants to accept arguments and return values in each of the floating-point types, double, float, and long double. A function typically uses the double type. A function of the same name with a suffix of "f" uses the float type and a function with a suffix of "l" uses the long double type. For example, math.h declares the cos(), cosf(), and cosl() functions. These functions all behave similarly but accept and return values of type double, float, and long double, respectively.
The macros defined in the tgmath.h header file choose and invoke a corresponding function in math.h or complex.h based on the types of the arguments passed to the macro.
| Macro | Math.h Variant | Complex.h Variant |
|---|---|---|
| acos() | acos | cacos |
| asin() | asin | casin |
| atan() | atan | catan |
| acosh() | acosh | cacosh |
| asinh() | asinh | casinh |
| atanh() | atanh | catanh |
| cos() | cos | ccos |
| sin() | sin | csin |
| tan() | tan | ctan |
| cosh() | cosh | ccosh |
| sinh() | sinh | csinh |
| tanh() | tanh | ctanh |
| exp() | exp | cexp |
| pow() | pow | cpow |
| sqrt() | sqrt | csqrt |
| fabs() | fabs | cabs |
| log() | log | clog |
| atan2() | atan2 | |
| cbrt() | cbrt | |
| ceil() | ceil | |
| copysign() | copysign | |
| erf() | erf | |
| erfc() | erfc | |
| exp2() | exp2 | |
| expm1() | expml | |
| fdim() | fdim | |
| floor() | floor | |
| fma() | fma | |
| fmax() | fmax | |
| fmin() | fmin | |
| fmod() | fmod | |
| frexp() | frexp | |
| hypot() | hypot | |
| ilogb() | ilogb | |
| ldexp() | ldexp | |
| lgamma() | lgamma | |
| llrint() | llrint | |
| llround() | llround | |
| log10() | log10 | |
| log1p() | log1p | |
| log2() | log2 | |
| logb() | logb | |
| lround() | lround | |
| lrint() | lrint | |
| nearbyint() | nearbyint | |
| nextafter() | nextafter | |
| nexttoward() | nexttoward | |
| remainder() | remainder | |
| remquo() | remquo | |
| rint() | rint | |
| round() | round | |
| scalbn() | scalbn | |
| scalbln() | scalbln | |
| tgamma() | tgamma | |
| trunc() | trunc | |
| carg() | carg | |
| cimag() | cimag | |
| conj() | conj | |
| cproj() | cproj | |
| creal() | creal |