math.h
The functions of math.h provide some common math functions that you may need to use in your calculations. Think of these as common calculations you might find on your calculator. There are far more function than these in the math.h library. For a more thorough listing see:
https://en.cppreference.com/w/c/numeric/math.html
math.h Library Functions
| Function | Purpose | Example |
|---|---|---|
ceil(x) | Returns smallest integer ≥ | ceil(4.3) → |
floor(x) | Returns largest integer ≤ | floor(4.7) → |
round(x) | Rounds to nearest integer | round(4.5) → |
fabs(x) | Returns absolute value of | fabs(-5.2) → |
sqrt(x) | Returns square root of | sqrt(16.0) → |
pow(x, y) | Returns raised to power | pow(2.0, 3.0) → |
exp(x) | Returns | exp(1.0) → |
log(x) | Returns natural logarithm of | log(2.718) → |
log10(x) | Returns base-10 logarithm of | log10(100.0) → |
sin(x) | Returns sine of (radians) | sin(0.0) → |
cos(x) | Returns cosine of (radians) | cos(0.0) → |
tan(x) | Returns tangent of (radians) | tan(0.0) → |
Note: All trigonometric functions use radians, not degrees. To convert degrees to radians, multiply by .