Facebook Page Twitter Page LinkedIn Page
× C++ Standard Library C++ STL Library


The C++ has a number of functions that are available for mathematical operation. These functions are available in <cmath> header file and available to use in a current program after including the header file - #include <cmath>. All functions of the header file are listed below. For more details about any one of these, please visit its page.

C++ Math Functions

Basic Math Functions

FunctionsDescription
abs() Returns the absolute (positive) value of the given number.
copysign() Returns a number with magnitude of first argument and sign of second argument.
fabs() Returns the absolute (positive) value of the given number.
fmax() Returns the number with maximum value.
fmin() Returns the number with minimum value.

Rounding & remainder Functions

FunctionsDescription
ceil() Rounds the given number up to the nearest integer.
floor() Rounds the given number down to the nearest integer.
fmod() Computes remainder of a division.
remainder() Computes remainder of a division.
remquo() Computes remainder and quotient of a division.
trunc() Rounds the given number towards zero.

Trigonometric Functions

FunctionsDescription
sin() Returns the trigonometric sine of an angle in radians.
cos() Returns the trigonometric cosine of an angle in radians.
tan() Returns the trigonometric tangent of an angle in radians.
asin() Returns the arc sine of a value.
acos() Returns the arc cosine of a value.
atan() Returns the arc tangent of a value.
atan2() Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta).

Hyperbolic Functions

FunctionsDescription
sinh() Returns the hyperbolic sine of a value.
cosh() Returns the hyperbolic cosine of a value.
tanh() Returns the hyperbolic tangent of a value.
asinh() Returns the inverse hyperbolic sine of a value
acosh() Returns the inverse hyperbolic cosine of a value
atanh() Returns the inverse hyperbolic tangent of a value

Power & Logarithmic Functions

FunctionsDescription
exp() Returns the exponent of e.
frexp() Get significand and exponent.
ldexp() Generate value from significand and exponent.
modf() Break the given number into fractional and integral parts.
expm1() Returns the exponent of e minus 1, i.e., ex-1.
exp2() Returns the exponent of 2, i.e., 2x.
log() Returns the natural logarithm of a given number.
log10() Returns the base-10 logarithm of a given number.
log1p() Returns the natural logarithm of (1+number), i.e., log(1+number).
log2() Returns the base-2 (binary) logarithm of a given number.
pow() Returns base raised to the power of exponent.
sqrt() Returns the square root of the given number.
cbrt() Returns the cube root of the given number.
hypot() Returns square root of sum of squares of two arguments, i.e., sqrt(x2 +y2).

Error & gamma Functions

FunctionsDescription
erf() Returns the error function of the argument.
erfc() Returns the complementary error function of the argument.