5.84 <tgmath.h> type-generic math macros in C99

The new standard header <tgmath.h> defines several families of mathematical functions that are type generic in the sense that they are overloaded on floating-point types.

For example, the trigonometric function cos works as if it has the overloaded declaration:

extern float cos(float x);
extern double cos(double x);
extern long double cos(long double x);

A statement such as:

p = cos(0.78539f); // p = cos(pi / 4)

calls the single-precision version of the cos function, as determined by the type of the literal 0.78539f.


Type-generic families of mathematical functions can be defined in C++ using the operator overloading mechanism. The semantics of type-generic families of functions defined using operator overloading in C++ are different from the semantics of the corresponding families of type-generic functions defined in <tgmath.h>.

Related concepts
5.64 New library features of C99
5.78 Additional <math.h> library functions in C99
5.79 Complex numbers in C99
5.80 Boolean type and <stdbool.h> in C99
5.81 Extended integer types and functions in <inttypes.h> and <stdint.h> in C99
5.82 <fenv.h> floating-point environment access in C99
5.83 <stdio.h> snprintf family of functions in C99
5.85 <wchar.h> wide character I/O functions in C99
Non-ConfidentialPDF file icon PDF versionARM DUI0472J
Copyright © 2010-2013 ARM. All rights reserved.