Common mathematical functions - cppreference.com (2024)

Defined in header <cstdlib>

abs(int)labsllabs

(C++11)

computes absolute value of an integral value (|x|)
(function) [edit]

div(int)ldivlldiv

(C++11)

computes quotient and remainder of integer division
(function) [edit]

Defined in header <cinttypes>

abs(std::intmax_t)imaxabs

(C++11)(C++11)

computes absolute value of an integral value (|x|)
(function) [edit]

div(std::intmax_t)imaxdiv

(C++11)(C++11)

computes quotient and remainder of integer division
(function) [edit]

Defined in header <cmath>

Basic operations

abs(float)fabsfabsffabsl

(C++11)(C++11)

absolute value of a floating point value (|x|)
(function) [edit]

fmodfmodffmodl

(C++11)(C++11)

remainder of the floating point division operation
(function) [edit]

remainderremainderfremainderl

(C++11)(C++11)(C++11)

signed remainder of the division operation
(function) [edit]

remquoremquofremquol

(C++11)(C++11)(C++11)

signed remainder as well as the three last bits of the division operation
(function) [edit]

fmafmaffmal

(C++11)(C++11)(C++11)

fused multiply-add operation
(function) [edit]

fmaxfmaxffmaxl

(C++11)(C++11)(C++11)

larger of two floating-point values
(function) [edit]

fminfminffminl

(C++11)(C++11)(C++11)

smaller of two floating point values
(function) [edit]

fdimfdimffdiml

(C++11)(C++11)(C++11)

positive difference of two floating point values (max(0, x-y))
(function) [edit]

nannanfnanl

(C++11)(C++11)(C++11)

not-a-number (NaN)
(function) [edit]
Exponential functions

expexpfexpl

(C++11)(C++11)

returns e raised to the given power (ex)
(function) [edit]

exp2exp2fexp2l

(C++11)(C++11)(C++11)

returns 2 raised to the given power (2x)
(function) [edit]

expm1expm1fexpm1l

(C++11)(C++11)(C++11)

returns e raised to the given power, minus one (ex-1)
(function) [edit]

loglogflogl

(C++11)(C++11)

computes natural (base e) logarithm (ln(x))
(function) [edit]

log10log10flog10l

(C++11)(C++11)

computes common (base 10) logarithm (log10(x))
(function) [edit]

log2log2flog2l

(C++11)(C++11)(C++11)

base 2 logarithm of the given number (log2(x))
(function) [edit]

log1plog1pflog1pl

(C++11)(C++11)(C++11)

natural logarithm (to base e) of 1 plus the given number (ln(1+x))
(function) [edit]
Power functions

powpowfpowl

(C++11)(C++11)

raises a number to the given power (xy)
(function) [edit]

sqrtsqrtfsqrtl

(C++11)(C++11)

computes square root (x)
(function) [edit]

cbrtcbrtfcbrtl

(C++11)(C++11)(C++11)

computes cube root (3x)
(function) [edit]

hypothypotfhypotl

(C++11)(C++11)(C++11)

computes square root of the sum of the squares of two or three(since C++17) given numbers (x2
+y2
), (x2
+y2
+z2
)
(since C++17)

(function) [edit]
Trigonometric functions

sinsinfsinl

(C++11)(C++11)

computes sine (sin(x))
(function) [edit]

coscosfcosl

(C++11)(C++11)

computes cosine (cos(x))
(function) [edit]

tantanftanl

(C++11)(C++11)

computes tangent (tan(x))
(function) [edit]

asinasinfasinl

(C++11)(C++11)

computes arc sine (arcsin(x))
(function) [edit]

acosacosfacosl

(C++11)(C++11)

computes arc cosine (arccos(x))
(function) [edit]

atanatanfatanl

(C++11)(C++11)

computes arc tangent (arctan(x))
(function) [edit]

atan2atan2fatan2l

(C++11)(C++11)

arc tangent, using signs to determine quadrants
(function) [edit]
Hyperbolic functions

sinhsinhfsinhl

(C++11)(C++11)

computes hyperbolic sine (sinh(x))
(function) [edit]

coshcoshfcoshl

(C++11)(C++11)

computes hyperbolic cosine (cosh(x))
(function) [edit]

tanhtanhftanhl

(C++11)(C++11)

computes hyperbolic tangent (tanh(x))
(function) [edit]

asinhasinhfasinhl

(C++11)(C++11)(C++11)

computes the inverse hyperbolic sine (arsinh(x))
(function) [edit]

acoshacoshfacoshl

(C++11)(C++11)(C++11)

computes the inverse hyperbolic cosine (arcosh(x))
(function) [edit]

atanhatanhfatanhl

(C++11)(C++11)(C++11)

computes the inverse hyperbolic tangent (artanh(x))
(function) [edit]
Error and gamma functions

erferfferfl

(C++11)(C++11)(C++11)

error function
(function) [edit]

erfcerfcferfcl

(C++11)(C++11)(C++11)

complementary error function
(function) [edit]

tgammatgammaftgammal

(C++11)(C++11)(C++11)

gamma function
(function) [edit]

lgammalgammaflgammal

(C++11)(C++11)(C++11)

natural logarithm of the gamma function
(function) [edit]
Nearest integer floating point operations

ceilceilfceill

(C++11)(C++11)

nearest integer not less than the given value
(function) [edit]

floorfloorffloorl

(C++11)(C++11)

nearest integer not greater than the given value
(function) [edit]

trunctruncftruncl

(C++11)(C++11)(C++11)

nearest integer not greater in magnitude than the given value
(function) [edit]

roundroundfroundllroundlroundflroundlllroundllroundfllroundl

(C++11)(C++11)(C++11)(C++11)(C++11)(C++11)(C++11)(C++11)(C++11)

nearest integer, rounding away from zero in halfway cases
(function) [edit]

nearbyintnearbyintfnearbyintl

(C++11)(C++11)(C++11)

nearest integer using current rounding mode
(function) [edit]

rintrintfrintllrintlrintflrintlllrintllrintfllrintl

(C++11)(C++11)(C++11)(C++11)(C++11)(C++11)(C++11)(C++11)(C++11)

nearest integer using current rounding mode with
exception if the result differs
(function) [edit]
Floating point manipulation functions

frexpfrexpffrexpl

(C++11)(C++11)

decomposes a number into significand and base-2 exponent
(function) [edit]

ldexpldexpfldexpl

(C++11)(C++11)

multiplies a number by 2 raised to an integral power
(function) [edit]

modfmodffmodfl

(C++11)(C++11)

decomposes a number into integer and fractional parts
(function) [edit]

scalbnscalbnfscalbnlscalblnscalblnfscalblnl

(C++11)(C++11)(C++11)(C++11)(C++11)(C++11)

multiplies a number by FLT_RADIX raised to a power
(function) [edit]

ilogbilogbfilogbl

(C++11)(C++11)(C++11)

extracts exponent of the number
(function) [edit]

logblogbflogbl

(C++11)(C++11)(C++11)

extracts exponent of the number
(function) [edit]

nextafternextafterfnextafterlnexttowardnexttowardfnexttowardl

(C++11)(C++11)(C++11)(C++11)(C++11)(C++11)

next representable floating-point value towards the given value
(function) [edit]

copysigncopysignfcopysignl

(C++11)(C++11)(C++11)

copies the sign of a floating point value
(function) [edit]
Classification and comparison

fpclassify

(C++11)

categorizes the given floating-point value
(function) [edit]

isfinite

(C++11)

checks if the given number has finite value
(function) [edit]

isinf

(C++11)

checks if the given number is infinite
(function) [edit]

isnan

(C++11)

checks if the given number is NaN
(function) [edit]

isnormal

(C++11)

checks if the given number is normal
(function) [edit]

signbit

(C++11)

checks if the given number is negative
(function) [edit]

isgreater

(C++11)

checks if the first floating-point argument is greater than the second
(function) [edit]

isgreaterequal

(C++11)

checks if the first floating-point argument is greater or equal than the second
(function) [edit]

isless

(C++11)

checks if the first floating-point argument is less than the second
(function) [edit]

islessequal

(C++11)

checks if the first floating-point argument is less or equal than the second
(function) [edit]

islessgreater

(C++11)

checks if the first floating-point argument is less or greater than the second
(function) [edit]

isunordered

(C++11)

checks if two floating-point values are unordered
(function) [edit]

Defined in header <cstdlib>

div_t

structure type, returned by std::div
(typedef) [edit]

ldiv_t

structure type, returned by std::ldiv
(typedef) [edit]

lldiv_t

(C++11)

structure type, returned by std::lldiv
(typedef) [edit]

Defined in header <cinttypes>

imaxdiv_t

(C++11)

structure type, returned by std::imaxdiv
(typedef) [edit]

Defined in header <cmath>

float_t

(C++11)

most efficient floating-point type at least as wide as float
(typedef) [edit]

double_t

(C++11)

most efficient floating-point type at least as wide as double
(typedef) [edit]

Defined in header <cmath>

HUGE_VALFHUGE_VALHUGE_VALL

(C++11)(C++11)

indicates the overflow value for float, double and long double respectively
(macro constant) [edit]

INFINITY

(C++11)

evaluates to positive infinity or the value guaranteed to overflow a float
(macro constant) [edit]

NAN

(C++11)

evaluates to a quiet NaN of type float
(macro constant) [edit]

math_errhandlingMATH_ERRNOMATH_ERREXCEPT

(C++11)(C++11)(C++11)

defines the error handling mechanism used by the common mathematical functions
(macro constant) [edit]
Classification

FP_NORMALFP_SUBNORMALFP_ZEROFP_INFINITEFP_NAN

(C++11)(C++11)(C++11)(C++11)(C++11)

indicates a floating-point category
(macro constant) [edit]
Mathematical special functions

C documentation for Common mathematical functions

Common mathematical functions - cppreference.com (2024)
Top Articles
Latest Posts
Article information

Author: Pres. Lawanda Wiegand

Last Updated:

Views: 5665

Rating: 4 / 5 (51 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Pres. Lawanda Wiegand

Birthday: 1993-01-10

Address: Suite 391 6963 Ullrich Shore, Bellefort, WI 01350-7893

Phone: +6806610432415

Job: Dynamic Manufacturing Assistant

Hobby: amateur radio, Taekwondo, Wood carving, Parkour, Skateboarding, Running, Rafting

Introduction: My name is Pres. Lawanda Wiegand, I am a inquisitive, helpful, glamorous, cheerful, open, clever, innocent person who loves writing and wants to share my knowledge and understanding with you.