A type-generic absolute value
#include <tgmath.h> double const a = -3.5; double magnitude = fabs(a); section 3.2
The <tgmath.h> header supplies type-generic macros for mathematical operations. An invocation such as fabs(a), sin(x), or pow(x, n) dispatches according to an argument's type and produces a result of the corresponding type. TAKEAWAY: include <tgmath.h> when one mathematical interface should work across supported numeric types. section 8.2
Absolute error in an iterative calculation
#include <tgmath.h> double const eps = 1E-9; double const a = 34.0; double x = 0.5; while (fabs(1.0 - a*x) >= eps) { x *= (2.0 - a*x); } Here fabs measures how far the product a*x is from 1.0. The loop applies Heron's approximation until the inverse estimate is sufficiently close. section 3.2
The header offers many related operations, including trigonometric, exponential, rounding, floating-point classification, and complex-number functions. Prefer these library facilities to handcrafted replacements: implementations may use processor-specific instructions and provide controlled numerical precision. section 8.2

