Common mathematical functions
From cppreference.com
Functions
Defined in header
<cstdlib> | |
(C++11) |
computes absolute value of an integral value (|x|) (function) |
(C++11) |
computes quotient and remainder of integer division (function) |
Defined in header
<cinttypes> | |
(C++11)(C++11) |
computes absolute value of an integral value (|x|) (function) |
(C++11)(C++11) |
computes quotient and remainder of integer division (function) |
Defined in header
<cmath> | |
Basic operations | |
(C++11)(C++11) |
absolute value of a floating point value (|x|) (function) |
(C++11)(C++11) |
remainder of the floating point division operation (function) |
(C++11)(C++11)(C++11) |
signed remainder of the division operation (function) |
(C++11)(C++11)(C++11) |
signed remainder as well as the three last bits of the division operation (function) |
(C++11)(C++11)(C++11) |
fused multiply-add operation (function) |
(C++11)(C++11)(C++11) |
larger of two floating-point values (function) |
(C++11)(C++11)(C++11) |
smaller of two floating point values (function) |
(C++11)(C++11)(C++11) |
positive difference of two floating point values (max(0, x-y)) (function) |
(C++11)(C++11)(C++11) |
not-a-number (NaN) (function) |
Exponential functions | |
(C++11)(C++11) |
returns e raised to the given power (ex) (function) |
(C++11)(C++11)(C++11) |
returns 2 raised to the given power (2x) (function) |
(C++11)(C++11)(C++11) |
returns e raised to the given power, minus 1 (ex-1) (function) |
(C++11)(C++11) |
computes natural (base e) logarithm (ln(x)) (function) |
(C++11)(C++11) |
computes common (base 10) logarithm (log10(x)) (function) |
(C++11)(C++11)(C++11) |
base 2 logarithm of the given number (log2(x)) (function) |
(C++11)(C++11)(C++11) |
natural logarithm (to base e) of 1 plus the given number (ln(1+x)) (function) |
Power functions | |
(C++11)(C++11) |
raises a number to the given power (xy) (function) |
(C++11)(C++11) |
computes square root (√x) (function) |
(C++11)(C++11)(C++11) |
computes cube root (3√x) (function) |
(C++11)(C++11)(C++11) |
computes hypotenuse √x2 +y2 and √x2 +y2 +z2 (since C++17) (function) |
Trigonometric functions | |
(C++11)(C++11) |
computes sine (sin(x)) (function) |
(C++11)(C++11) |
computes cosine (cos(x)) (function) |
(C++11)(C++11) |
computes tangent (tan(x)) (function) |
(C++11)(C++11) |
computes arc sine (arcsin(x)) (function) |
(C++11)(C++11) |
computes arc cosine (arccos(x)) (function) |