<math.h> provides standard math functions: trigonometric, exponential, logarithmic, rounding, and IEEE 754 utilities (isnan, isinf). Append f for float or l for long double versions.
Compile with -lm to link the math library.
This example demonstrates basic math functions and special-value checking.
// compile: gcc -o mathexample mathexample.c -lm // run: ./mathexample // description: math functions and special value detection #include <math.h> #include <stdio.h> int main() { printf("sqrt(2) = %.6f\n", sqrt(2.0)); printf("sin(pi/4) = %.6f\n", sin(M_PI / 4)); printf("exp(1) = %.6f\n", exp(1.0)); printf("log(10) = %.6f\n", log(10.0)); double nan_val = 0.0 / 0.0; double inf_val = 1.0 / 0.0; printf("isnan(nan): %d, isinf(inf): %d\n", isnan(nan_val), isinf(inf_val)); return 0; }