Common mathematical functions
Functions
Defined in header <cstdlib>
abs labs llabs | Computes absolute value of an integral value (|x|) | |
div ldiv lldiv | Computes quotient and remainder of integer division |
Defined in header <cinttypes>
abs imaxabs | Computes absolute value of an integral value (|x|) | |
div imaxdiv | Computes quotient and remainder of integer division |
Defined in header <cmath>
Basic operations
abs fabs fabsf fabsl | Absolute value of a floating point value (|x|) | |
fmod fmodf fmodl | Remainder of the floating point division operation | |
remainder remainderf remainderl | Signed remainder of the division operation | |
remquo remquof remquol | Signed remainder as well as the three last bits of the division operation | |
fma fmaf fmal | Fused multiply-add operation | |
fmax fmaxf fmaxl | Larger of two floating-point values | |
fmin fminf fminl | Smaller of two floating point values | |
fdim fdimf fdiml | Positive difference of two floating point values (max(0, x - y)) | |
nan nanf nanl | not-a-number (NaN) |
Exponential functions
exp expf expl | Returns e raised to the given power (ex) | |
exp2 exp2f exp2l | Returns 2 raised to the given power (2x) | |
expm1 expm1f expm1l | Returns e raised to the given power, minues one (ex - 1) | |
log logf logl | Computes natural (base e) logarithm (ln x) | |
log10 log10f log10l | Computes common (base 10) logarithm (log10x) | |
log2 log2f log2l | Base 2 logarithm of the given number (log2x) | |
log1p log1pf log1pl | Natural logarithm (to base e) of 1 plus the given number(ln(1 + x)) |
Power functions
pow powf powl | Raises a number to the given power (xy) | |
sqrt sqrtf sqrtl | Computes square root (√x) | |
cbrt cbrtf cbrtl | Computes cubic root (∛x) | |
hypot hypotf hypotl | Computes square root of the sum of the squares of two or three given numbers (√x2+y2) |
Trigonometric functions
sin sinf sinl | Computes sine (sin x) | |
cos cosf cosl | Computes cosine (cos x) | |
tan tanf tanl | Computes tangent (tan x) | |
asin asinf asinl | Computes arc sine (arcsin x) | |
acos acosf acosl | Computes arc cosine (arccos x) | |
atan atanf atanl | Computes arc tangent (arctan x) | |
atan2 atan2f atan2l | Arc tangent, using signs to determine quadrants |
Hyperbolic functions
sinh sinhf sinhl | Computes hyperbolic sine (sinh x) | |
cosh coshf coshl | Computes hyperbolic cosine (cosh x) | |
tanh tanhf tanhl | Computes hyperbolic tangent (tanh x) | |
asinh asinhf asinhl | Computes the inverse hyperbolic sine (arsinh x) | |
acosh acoshf acoshl | Computes the inverse hyperbolic cosine (arcosh x) | |
atanh atanhf atanhl | Computes the inverse hyperbolic tangent (artanh x) |
Error and gamma functions
erf erff erfl | Error function | |
erfc erfcf erfcl | Complementary error function | |
tgamma tgammaf tgammal | Gamma function | |
lgamma lgammaf lgammal | Natural logarithm of the gamma function |
Nearest integer floating point operations
ceil ceilf ceill | Nearest integer not less than the given value | |
floor floorf floorl | Nearest integer not greater than the given value | |
trunc truncf truncl | Nearest integer not greater in magnitude than the given value | |
round roundf roundl lround lroundf lroundl llround llroundf llroundl | Nearest integer, rounding away from zero in halfway cases | |
nearbyint nearbyintf nearbyintl | Nearest integer using current rounding mode | |
rint rintf rintl lrint lrintf lrintl llrint llrintf llrintl | Nearest integer using current rounding mode with exception if t he result differs |
Floating point manipulation functions
frexp frexpf frexpl | Decomposes a number into significand and a power of 2 | |
ldexp ldexpf ldexpl | Multiplies a number by 2 raised to a power | |
modf modff modfl | Decomposes a number into integer and fractional parts | |
scalbn scalbnf scalbnl scalbln scalblnf scalblnl | Multiplies a number by FLT_RADIX raised to a power | |
ilogb ilogbf ilogbl | Extracts exponent of the number | |
logb logbf logbl | Extracts exponent of the number | |
nextafter nextafterf nextafterl nexttoward nexttowardf nexttowardl | Next representable floating point value towards the given value | |
copysign copysignf copysignl | Copies the sign of a floating point value |
Classification and comparison
fpclassify | Categorizes the given floating point value | |
isfinite | Checks if the given number has finite value | |
isinf | Checks if the given number is infinite | |
isnan | Checks if the given number is NaN | |
isnormal | Checks if the given number is normal | |
signbit | Checks if the given number is negative | |
isgreater | Checks if the first floating-point argument is greater then the second | |
isgreaterequal | Checks if the first floating-point argument is greater or equal then the second | |
isless | Checks if the first floating-point argument is less than the second | |
islessequal | Checks if the first floating-point argument is less or equal than the second | |
islessgreater | Checks if the first floating-point argument is less or greater than the second | |
isunordered | Checks if two floating-point values are unordered |
Types
Defined in header <cstdlib>
div_t | Structure type, return of the std::div function | |
ldiv_t | Structure type, return of the std::ldiv function | |
lldiv_t | Structure type, return of the std::lldiv function | |
imaxdiv_t | Structure type, return of the std::imaxdiv function | |
float_t | Most efficient floating-point type at least as wide as float | |
double_t | Most efficient floating-point type at least as wide as double |
Macro constants
Defined in header <cmath>
HUGE_VALF HUGE_VAL HUGE_VALL | Indicates the overflow value for float , double and long double respectively | |
INFINITY | Evaluates to positive infinity or the value guaranteed to overflow a float | |
NAN | Evaluates to a quiet NaN of type float | |
math_errhandling MATH_ERRNO MATH_ERREXCEPT | Defines the error handling mechanism used by the common mathematical functions |
Classification
FP_NORMAL FP_SUBNORMAL FP_ZERO FP_INFINITE FP_NAN | Indicates a floating-point category |