Common mathematical functions - cppreference.com (2024)

Defined in header <stdlib.h>

abslabsllabs

(C99)

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

divldivlldiv

(C99)

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

Defined in header <inttypes.h>

imaxabs

(C99)

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

imaxdiv

(C99)

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

Defined in header <math.h>

Basic operations

fabsfabsffabsl

(C99)(C99)

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

fmodfmodffmodl

(C99)(C99)

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

remainderremainderfremainderl

(C99)(C99)(C99)

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

remquoremquofremquol

(C99)(C99)(C99)

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

fmafmaffmal

(C99)(C99)(C99)

computes fused multiply-add operation
(function) [edit]

fmaxfmaxffmaxl

(C99)(C99)(C99)

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

fminfminffminl

(C99)(C99)(C99)

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

fdimfdimffdiml

(C99)(C99)(C99)

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

nannanfnanl

(C99)(C99)(C99)

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

expexpfexpl

(C99)(C99)

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

exp2exp2fexp2l

(C99)(C99)(C99)

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

expm1expm1fexpm1l

(C99)(C99)(C99)

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

loglogflogl

(C99)(C99)

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

log10log10flog10l

(C99)(C99)

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

log2log2flog2l

(C99)(C99)(C99)

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

powpowfpowl

(C99)(C99)

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

sqrtsqrtfsqrtl

(C99)(C99)

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

cbrtcbrtfcbrtl

(C99)(C99)(C99)

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

hypothypotfhypotl

(C99)(C99)(C99)

computes square root of the sum of the squares of two given numbers (x2
+y2
)
(function) [edit]
Trigonometric functions

sinsinfsinl

(C99)(C99)

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

coscosfcosl

(C99)(C99)

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

tantanftanl

(C99)(C99)

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

asinasinfasinl

(C99)(C99)

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

acosacosfacosl

(C99)(C99)

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

atanatanfatanl

(C99)(C99)

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

atan2atan2fatan2l

(C99)(C99)

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

sinhsinhfsinhl

(C99)(C99)

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

coshcoshfcoshl

(C99)(C99)

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

tanhtanhftanhl

(C99)(C99)

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

asinhasinhfasinhl

(C99)(C99)(C99)

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

acoshacoshfacoshl

(C99)(C99)(C99)

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

atanhatanhfatanhl

(C99)(C99)(C99)

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

erferfferfl

(C99)(C99)(C99)

computes error function
(function) [edit]

erfcerfcferfcl

(C99)(C99)(C99)

computes complementary error function
(function) [edit]

tgammatgammaftgammal

(C99)(C99)(C99)

computes gamma function
(function) [edit]

lgammalgammaflgammal

(C99)(C99)(C99)

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

ceilceilfceill

(C99)(C99)

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

floorfloorffloorl

(C99)(C99)

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

trunctruncftruncl

(C99)(C99)(C99)

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

roundroundfroundllroundlroundflroundlllroundllroundfllroundl

(C99)(C99)(C99)(C99)(C99)(C99)(C99)(C99)(C99)

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

nearbyintnearbyintfnearbyintl

(C99)(C99)(C99)

rounds to an integer using current rounding mode
(function) [edit]

rintrintfrintllrintlrintflrintlllrintllrintfllrintl

(C99)(C99)(C99)(C99)(C99)(C99)(C99)(C99)(C99)

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

frexpfrexpffrexpl

(C99)(C99)

breaks a number into significand and a power of 2
(function) [edit]

ldexpldexpfldexpl

(C99)(C99)

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

modfmodffmodfl

(C99)(C99)

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

scalbnscalbnfscalbnlscalblnscalblnfscalblnl

(C99)(C99)(C99)(C99)(C99)(C99)

computes efficiently a number times FLT_RADIX raised to a power
(function) [edit]

ilogbilogbfilogbl

(C99)(C99)(C99)

extracts exponent of the given number
(function) [edit]

logblogbflogbl

(C99)(C99)(C99)

extracts exponent of the given number
(function) [edit]

nextafternextafterfnextafterlnexttowardnexttowardfnexttowardl

(C99)(C99)(C99)(C99)(C99)(C99)

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

copysigncopysignfcopysignl

(C99)(C99)(C99)

produces a value with the magnitude of a given value and the sign of another given value
(function) [edit]
Classification and comparison

fpclassify

(C99)

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

isfinite

(C99)

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

isinf

(C99)

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

isnan

(C99)

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

isnormal

(C99)

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

signbit

(C99)

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

isgreater

(C99)

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

isgreaterequal

(C99)

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

isless

(C99)

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

islessequal

(C99)

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

islessgreater

(C99)

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

isunordered

(C99)

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

Defined in header <stdlib.h>

div_t

structure type, return of the div function
(typedef) [edit]

ldiv_t

structure type, return of the ldiv function
(typedef) [edit]

lldiv_t

(C99)

structure type, return of the lldiv function
(typedef) [edit]

Defined in header <inttypes.h>

imaxdiv_t

(C99)

structure type, return of the imaxdiv function
(typedef) [edit]

Defined in header <math.h>

float_tdouble_t

(C99)(C99)

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

Defined in header <math.h>

HUGE_VALFHUGE_VALHUGE_VALL

(C99)(C99)

indicates value too big to be representable (infinity) by float, double and long double respectively
(macro constant) [edit]

INFINITY

(C99)

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

NAN

(C99)

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

FP_FAST_FMAFFP_FAST_FMAFP_FAST_FMAL

(C99)(C99)(C99)

indicates that the fma function generally executes about as fast as, or faster than, a multiply and an add of double operands
(macro constant) [edit]

FP_ILOGB0FP_ILOGBNAN

(C99)(C99)

evaluates to ilogb(x) if x is zero or NaN, respectively
(macro constant) [edit]

math_errhandlingMATH_ERRNOMATH_ERREXCEPT

(C99)(C99)(C99)

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

FP_NORMALFP_SUBNORMALFP_ZEROFP_INFINITEFP_NAN

(C99)(C99)(C99)(C99)(C99)

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

C++ documentation for Common mathematical functions

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

Author: Msgr. Benton Quitzon

Last Updated:

Views: 5891

Rating: 4.2 / 5 (43 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Msgr. Benton Quitzon

Birthday: 2001-08-13

Address: 96487 Kris Cliff, Teresiafurt, WI 95201

Phone: +9418513585781

Job: Senior Designer

Hobby: Calligraphy, Rowing, Vacation, Geocaching, Web surfing, Electronics, Electronics

Introduction: My name is Msgr. Benton Quitzon, I am a comfortable, charming, thankful, happy, adventurous, handsome, precious person who loves writing and wants to share my knowledge and understanding with you.