Tgmath.h
tgmath.h is the C standard header providing type-generic macros that select mathematical functions according to argument types.
Modern C
tgmath.h is the C standard header that provides type-generic macros for mathematical functions.
- How it is used
- Provides one type-generic interface for invoking mathematical operations across numeric argument types.
- How deep it goes
- Explains type-based dispatch and surveys function families, but defers detailed descriptions of the complete macro set.
- Examples
- Uses fabs in an iterative Heron approximation that computes multiplicative inverses and tests absolute error against a tolerance.
- What you can do after
- Apply it via <tgmath.h> macros and select established numerical operations instead of reimplementing them by hand.
Modern C, Third Edition
tgmath is the C type-generic mathematics facility that provides interfaces selecting numerical functions according to argument types.
- How it is used
- Provides type-appropriate interfaces for numerical calculations while reducing the need to select floating-point variants manually.
- How deep it goes
- Explains argument-based dispatch and implementation rationale, but does not enumerate every macro or specify dispatch mechanics in detail.
- Examples
- Uses fabs in a Heron-approximation loop that computes multiplicative inverses from command-line numbers.
- What you can do after
- Apply it via <tgmath.h> macros and choose established numerical interfaces instead of reimplementing floating-point operations.
Related concepts
- type-generic macrohas part · A type-generic macro is a macro-based interface whose expansion selects or adapts operations according to the types of its arguments or associated objects.
- sqrtused by · sqrt is a mathematical function that returns the principal square root of a nonnegative numeric value.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

