C++ provides some basic mathematical functions, and the header file required is <math.h>.
Trigonometric Functions
| Method |
Description |
| cos(x) |
Calculates the cosine of x. |
| sin(x) |
Calculates the sine of x. |
| tan(x) |
Calculates the tangent of x. |
| acos(x) |
Calculates the arccosine of x. |
| asin(x) |
Calculates the arcsine of x. |
| atan(x) |
Calculates the arctangent of x. |
| atan2(x,y) |
Calculates the arctangent of the coordinates x and y. |
👇Click to receive👇
👉Collection of C Language Knowledge Materials
Hyperbolic Functions
| Method |
Description |
| cosh(x) |
Calculates the hyperbolic cosine of x. |
| sinh(x) |
Calculates the hyperbolic sine of x. |
| tanh(x) |
Calculates the hyperbolic tangent of x. |
| acosh(x) |
Calculates the inverse hyperbolic cosine of x. |
| asinh(x) |
Calculates the inverse hyperbolic sine of x. |
| atanh(x) |
Calculates the inverse hyperbolic tangent of x. |
Exponential Functions
| Method |
Description |
| exp(x) |
Calculates e raised to the power of x. |
| frexp(value_type x,int* exp) |
Decomposes a number into its mantissa and exponent. |
| ldexp(float x, int e) |
Calculates x multiplied by 2 raised to the power of e. |
| log(x) |
Calculates the natural logarithm of x. |
| log10(x) |
Calculates the common logarithm of x. |
| modf() |
Decomposes a number into its integer and fractional parts. |
| exp2(x) |
Calculates 2 raised to the power of x. |
| expm1(x) |
Calculates e raised to the power of x minus 1. |
| log1p(x) |
Calculates the natural logarithm of x plus 1. |
| log2(x) |
Calculates the logarithm of x base 2. |
| logb(x) |
Calculates the logarithm of x. |
| scalbn(x, n) |
Calculates x multiplied by FLT_RADIX raised to the power of n. |
| scalbln(x, n) |
Calculates x multiplied by FLT_RADIX raised to the power of n. |
| ilogb(x) |
Returns the exponent part of x. |
Floating Point Operation Functions
| Method |
Description |
| copysign(x,y) |
Returns the absolute value of x with the sign of y. |
| nextafter(x,y) |
Returns the closest representable value to x in the direction of y. |
| nexttoward(x,y) |
Returns the closest representable value to x in the direction of y. |
Max, Min and Difference Functions
| Method |
Description |
| fdim(x,y) |
Calculates the positive difference between x and y. |
| fmax(x,y) |
Returns the larger of x and y. |
| fmin() |
Returns the smaller of x and y. |
Power Functions
| Method |
Description |
| pow(x,y) |
Calculates x raised to the power of y. |
| sqrt(x) |
Calculates the square root of x. |
| cbrt(x) |
Calculates the cube root of x. |
| hypot(x,y) |
Calculates the hypotenuse of a right triangle. |
Rounding Functions
| Method |
Description |
| ceil(x) |
Rounds x up to the nearest integer. |
| floor(x) |
Rounds x down to the nearest integer. |
| round(x) |
Rounds x to the nearest integer value. |
| lround(x) |
Rounds x to the nearest integer and converts to long. |
| llround(x) |
Rounds x to the nearest integer and converts to long long. |
| fmod(n,d) |
Calculates the remainder of n divided by d. |
| trunc(x) |
Truncates x towards zero. |
| rint(x) |
Rounds x according to the rounding mode. |
| lrint(x) |
Rounds x according to the rounding mode and converts to long. |
| llrint(x) |
Rounds x to the nearest integer and converts to long long. |
| nearbyint(x) |
Rounds x to the nearest integer value. |
| remainder(n,d) |
Calculates the remainder of n divided by d. |
| remquo() |
Calculates the remainder and quotient. |
Other Functions
| Method |
Description |
| fabs(x) |
Calculates the absolute value of x. |
| abs(x) |
Calculates the absolute value of x. |
| fma(x,y,z) |
Calculates the value of the expression x*y+z. |
Macro Functions
| Method |
Description |
| fpclassify(x) x |
signbit(x) Checks if the sign of x is negative. |
| isfinite(x) |
Checks if x is a finite number. |
| isinf() |
Checks if x is infinite. |
| isnan() |
Checks if x is NaN. |
| isnormal(x) |
Checks if x is a normal number. |
| signbit(x) |
Checks if the sign of x is negative. |
Comparison Macro Functions
| Method |
Description |
| isgreater(x,y) |
Checks if x is greater than y. |
| isgreaterequal(x,y) |
Checks if x is greater than or equal to y. |
| less(x,y) |
Checks if x is less than y. |
| islessequal(x,y) |
Checks if x is less than or equal to y. |
| islessgreater(x,y) |
Checks if x is less than or greater than y. |
| isunordered(x,y) |
Checks if x can be meaningfully compared. |
Error and Gamma Functions
| Method |
Description |
| erf(x) |
Calculates the error function value of x. |
| erfc(x) |
Calculates the complementary error function value of x. |
| tgamma(x) |
Calculates the gamma function value of x. |
| lgamma(x) |
Calculates the logarithm of the gamma function of x. |

Popular Recommendations
-
CLion Tutorial – Running CMake Targets Before Launching CLion
-
C Language Algorithm – “Removing Duplicates II” Algorithm Problem
-
C++ Tutorial – Detailed Explanation of Friend Functions in C++