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.
What to know first
- fused multiply-addA fused multiply-add is an arithmetic operation that multiplies two values, adds a third, and rounds the result once.
- scopeScope is the region of a program in which names are visible and can be resolved to their bindings according to the language’s rules.
- size_tsize_t is an unsigned integer type in C and C++ used to represent object sizes and related counts.
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.
Questions about tgmath.h
What is tgmath.h?
tgmath.h is the C standard header providing type-generic macros that select mathematical functions according to argument types.
Which Manning books explain tgmath.h?
Modern C and Modern C, Third Edition.
What should I know before learning tgmath.h?
Manning books that teach tgmath.h usually introduce fused multiply-add, scope and size_t first.
What are the parts of tgmath.h?
Tgmath.h includes type-generic macro.
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.

