Common mathematical functions

From Cppreference

Jump to: navigation, search

Contents

Functions

Basic operations
abs(int)
labs
llabs
computes absolute value of an integral value (|x|)
(function)
abs(float)
fabs
absolute value of an absolute value of an floating point value (|x|)
(function)
div
ldiv
lldiv
the quotient and remainder of integer division
(function)
fmod
remainder of the floating point division operation
(function)
remainder (C++11)
signed remainder of the division operation
(function)
remquo (C++11)
signed remainder as well as the three last bits of the division operation
(function)
fma (C++11)
fused multiply-add operation
(function)
fmax (C++11)
larger of two floating point values
(function)
fmin (C++11)
smaller of two floating point values
(function)
fdim (C++11)
positive difference of two floating point values (max(0, x-y))
(function)
nan
nanf
nanl
(C++11)
(C++11)
(C++11)
not-a-number (NaN)
(function)
Exponential functions
exp
returns e raised to the given power (ex)
(function)
exp2 (C++11)
returns 2 raised to the given power (2x)
(function)
expm1 (C++11)
returns e raised to the given power, minus one (ex-1)
(function)
log
computes natural (base e) logarithm (to base e) (ln(x))
(function)
log10
computes common (base 10) logarithm (log10(x))
(function)
log1p (C++11)
natural logarithm (to base e) of 1 plus the given number
(function)
ilogb (C++11)
extracts exponent of the number
(function)
logb (C++11)
extracts exponent of the number
(function)
Power functions
sqrt
computes square root (x)
(function)
cbrt (C++11)
computes cubic root (3x)
(function)
hypot (C++11)
computes square root of the sum of the squares of two given numbers (x2
+y2
)
(function)
pow
raises a number to the given power (xy)
(function)
Trigonometric functions
sin
computes sine (sin(x))
(function)
cos
computes cosine (cos(x))
(function)
tan
computes tangent (tan(x))
(function)
asin
computes arc sine (arcsin(x))
(function)
acos
computes arc cosine (arccos(x))
(function)
atan
computes arc tangent (arctan(x))
(function)
atan2
arc tangent, using signs to determine quadrants
(function)
Hyperbolic functions
sinh
computes hyperbolic sine (sh(x))
(function)
cosh
computes hyperbolic cosine (ch(x))
(function)
tanh
hyperbolic tangent
(function)
asinh (C++11)
hyperbolic arc sine
(function)
acosh (C++11)
hyperbolic arc cosine
(function)
atanh (C++11)
hyperbolic arc tangent
(function)
Error and gamma functions
erf (C++11)
error function
(function)
erfc (C++11)
complementary error function
(function)
lgamma (C++11)
natural logarithm of the gamma function
(function)
tgamma (C++11)
gamma function
(function)
Nearest integer floating point operations
ceil
nearest integer not less than the given value
(function)
floor
nearest integer not greater than the given value
(function)
trunc (C++11)
nearest integer not greater in magnitude than the given value
(function)
round
lround
llround
(C++11)
(C++11)
(C++11)
nearest integer, rounding away from zero in halfway cases
(function)
nearbyint (C++11)
nearest integer using current rounding mode
(function)
rint
lrint
llrint
(C++11)
(C++11)
(C++11)
nearest integer using current rounding mode with
exception if the result differs
(function)
Floating point manipulation functions
frexp
decomposes a number into significand and a power of 2
(function)
ldexp
multiplies a number by 2 raised to a power
(function)
modf
decomposes a number into integer and fractional parts
(function)
scalbn
scalbln
(C++11)
(C++11)
multiplies a number by FLT_RADIX raised to a power
(function)
nextafter
nexttoward
(C++11)
(C++11)
next representable floating point value towards the given value
(function)
copysign (C++11)
copies the sign of a floating point value
(function)
Classification
fpclassify (C++11)
categorizes the given floating point value
(function)
isfinite (C++11)
checks if the given number has finite value
(function)
isinf (C++11)
checks if the given number is infinite
(function)
isnan (C++11)
checks if the given number is NaN
(function)
isnormal (C++11)
checks if the given number is normal
(function)
signbit (C++11)
checks if the given number is negative
(function)

Macro constants

HUGE_VAL
indicates value too big to be representable (infinity) by double
(macro constant)
HUGE_VALF (C++11)
indicates value too big to be representable (infinity) by float
(macro constant)
HUGE_VALL (C++11)
indicates value too big to be representable (infinity) by long double
(macro constant)
Classification
FP_INFINITE (C++11)
indicates infinite floating point value
(macro constant)
FP_NAN (C++11)
indicates not-a-number (NaN)
(macro constant)
FP_NORMAL (C++11)
indicates normal number
(macro constant)
FP_SUBNORMAL (C++11)
indicates subnormal number
(macro constant)
FP_ZERO (C++11)
indicates zero
(macro constant)