Standard library header <cmath>
该头文件最初作为 <math.h> 存在于C标准库中。
此头文件是 数值 库的组成部分。
Types |
|
|
float_t
(C++11)
|
most efficient floating-point type at least as wide as
float
(typedef) |
|
double_t
(C++11)
|
most efficient floating-point type at least as wide as
double
(typedef) |
Macros |
|
|
(C++11)
(C++11)
|
indicates the overflow value for
float
,
double
and
long
double
respectively
(macro constant) |
|
(C++11)
|
evaluates to positive infinity or the value guaranteed to overflow a
float
(macro constant) |
|
(C++11)
|
evaluates to a quiet NaN of type
float
(macro constant) |
|
(C++11)
(C++11)
(C++11)
|
defines the error handling mechanism used by the common mathematical functions
(macro constant) |
Classification |
|
|
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
|
indicates a floating-point category
(macro constant) |
Functions |
|
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) |
Linear interpolation |
|
|
(C++20)
|
linear interpolation function
(function) |
Exponential functions |
|
|
(C++11)
(C++11)
|
returns
e
raised to the given power (
e
x
)
(function) |
|
(C++11)
(C++11)
(C++11)
|
returns
2
raised to the given power (
2
x
)
(function) |
|
(C++11)
(C++11)
(C++11)
|
returns
e
raised to the given power, minus
1
(
e
x
-1
)
(function) |
|
(C++11)
(C++11)
|
computes natural (base
e
) logarithm (
ln(x)
)
(function) |
|
(C++11)
(C++11)
|
computes common (base
10
) logarithm (
log
10
(x)
)
(function) |
|
(C++11)
(C++11)
(C++11)
|
base
2
logarithm of the given number (
log
2
(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 (
x
y
)
(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
√
x
2
+y 2 and √ x 2 +y 2 +z 2 (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) |
|
(C++11)
(C++11)
|
computes arc tangent (
arctan(x)
)
(function) |
|
(C++11)
(C++11)
|
arc tangent, using signs to determine quadrants
(function) |
Hyperbolic functions |
|
|
(C++11)
(C++11)
|
computes hyperbolic sine (
sinh(x)
)
(function) |
|
(C++11)
(C++11)
|
computes hyperbolic cosine (
cosh(x)
)
(function) |
|
(C++11)
(C++11)
|
computes hyperbolic tangent (
tanh(x)
)
(function) |
|
(C++11)
(C++11)
(C++11)
|
computes the inverse hyperbolic sine (
arsinh(x)
)
(function) |
|
(C++11)
(C++11)
(C++11)
|
computes the inverse hyperbolic cosine (
arcosh(x)
)
(function) |
|
(C++11)
(C++11)
(C++11)
|
computes the inverse hyperbolic tangent (
artanh(x)
)
(function) |
Error and gamma functions |
|
|
(C++11)
(C++11)
(C++11)
|
error function
(function) |
|
(C++11)
(C++11)
(C++11)
|
complementary error function
(function) |
|
(C++11)
(C++11)
(C++11)
|
gamma function
(function) |
|
(C++11)
(C++11)
(C++11)
|
natural logarithm of the gamma function
(function) |
Nearest integer floating-point operations |
|
|
(C++11)
(C++11)
|
nearest integer not less than the given value
(function) |
|
(C++11)
(C++11)
|
nearest integer not greater than the given value
(function) |
|
(C++11)
(C++11)
(C++11)
|
nearest integer not greater in magnitude than the given value
(function) |
|
(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) |
|
(C++11)
(C++11)
(C++11)
|
nearest integer using current rounding mode
(function) |
|
(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) |
Floating-point manipulation functions |
|
|
(C++11)
(C++11)
|
decomposes a number into significand and base-
2
exponent
(function) |
|
(C++11)
(C++11)
|
multiplies a number by
2
raised to an integral power
(function) |
|
(C++11)
(C++11)
|
decomposes a number into integer and fractional parts
(function) |
|
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
|
multiplies a number by
FLT_RADIX
raised to a power
(function) |
|
(C++11)
(C++11)
(C++11)
|
extracts exponent of the number
(function) |
|
(C++11)
(C++11)
(C++11)
|
extracts exponent of the number
(function) |
|
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
|
next representable floating-point value towards the given value
(function) |
|
(C++11)
(C++11)
(C++11)
|
copies the sign of a floating point value
(function) |
Classification and comparison |
|
|
(C++11)
|
categorizes the given floating-point value
(function) |
|
(C++11)
|
checks if the given number has finite value
(function) |
|
(C++11)
|
checks if the given number is infinite
(function) |
|
(C++11)
|
checks if the given number is NaN
(function) |
|
(C++11)
|
checks if the given number is normal
(function) |
|
(C++11)
|
checks if the given number is negative
(function) |
|
(C++11)
|
checks if the first floating-point argument is greater than the second
(function) |
|
(C++11)
|
checks if the first floating-point argument is greater or equal than the second
(function) |
|
(C++11)
|
checks if the first floating-point argument is less than the second
(function) |
|
(C++11)
|
checks if the first floating-point argument is less or equal than the second
(function) |
|
(C++11)
|
checks if the first floating-point argument is less or greater than the second
(function) |
|
(C++11)
|
checks if two floating-point values are unordered
(function) |
Mathematical special functions |
|
|
(C++17)
(C++17)
(C++17)
|
associated Laguerre polynomials
(function) |
|
(C++17)
(C++17)
(C++17)
|
associated Legendre polynomials
(function) |
|
(C++17)
(C++17)
(C++17)
|
beta function
(function) |
|
(C++17)
(C++17)
(C++17)
|
(complete) elliptic integral of the first kind
(function) |
|
(C++17)
(C++17)
(C++17)
|
(complete) elliptic integral of the second kind
(function) |
|
(C++17)
(C++17)
(C++17)
|
(complete) elliptic integral of the third kind
(function) |
|
(C++17)
(C++17)
(C++17)
|
regular modified cylindrical Bessel functions
(function) |
|
(C++17)
(C++17)
(C++17)
|
cylindrical Bessel functions (of the first kind)
(function) |
|
(C++17)
(C++17)
(C++17)
|
irregular modified cylindrical Bessel functions
(function) |
|
(C++17)
(C++17)
(C++17)
|
cylindrical Neumann functions
(function) |
|
(C++17)
(C++17)
(C++17)
|
(incomplete) elliptic integral of the first kind
(function) |
|
(C++17)
(C++17)
(C++17)
|
(incomplete) elliptic integral of the second kind
(function) |
|
(C++17)
(C++17)
(C++17)
|
(incomplete) elliptic integral of the third kind
(function) |
|
(C++17)
(C++17)
(C++17)
|
exponential integral
(function) |
|
(C++17)
(C++17)
(C++17)
|
Hermite polynomials
(function) |
|
(C++17)
(C++17)
(C++17)
|
Legendre polynomials
(function) |
|
(C++17)
(C++17)
(C++17)
|
Laguerre polynomials
(function) |
|
(C++17)
(C++17)
(C++17)
|
Riemann zeta function
(function) |
|
(C++17)
(C++17)
(C++17)
|
spherical Bessel functions (of the first kind)
(function) |
|
(C++17)
(C++17)
(C++17)
|
spherical associated Legendre functions
(function) |
|
(C++17)
(C++17)
(C++17)
|
spherical Neumann functions
(function) |
概要
对于每个至少包含一个 /* floating-point-type */ 类型参数的函数,都会为每个无cv限定符的浮点类型提供一个重载版本,其中函数签名中所有 /* floating-point-type */ 的使用都将被替换为该浮点类型。
对于每个至少有一个
/* 浮点类型 */
参数(除
std::abs
外)的函数,均提供了额外的重载以确保:若每个对应
/* 浮点类型 */
参数的实参均具有算术类型,则每个此类实参都会被隐式转换为具有最高
浮点转换等级
和最高
浮点转换子等级
的浮点类型(该等级从所有此类实参的类型中选取),其中整数类型的实参被视为具有与
double
相同的浮点转换等级。若不存在具有最高等级和子等级的浮点类型,则重载解析无法从提供的重载中得到可用候选。
namespace std { using float_t = /* 参见描述 */; using double_t = /* 参见描述 */; } #define HUGE_VAL /* 参见描述 */ #define HUGE_VALF /* 参见描述 */ #define HUGE_VALL /* 参见描述 */ #define INFINITY /* 参见描述 */ #define NAN /* 参见描述 */ #define FP_INFINITE /* 参见描述 */ #define FP_NAN /* 参见描述 */ #define FP_NORMAL /* 参见描述 */ #define FP_SUBNORMAL /* 参见描述 */ #define FP_ZERO /* 参见描述 */ #define FP_FAST_FMA /* 参见描述 */ #define FP_FAST_FMAF /* 参见描述 */ #define FP_FAST_FMAL /* 参见描述 */ #define FP_ILOGB0 /* 参见描述 */ #define FP_ILOGBNAN /* 参见描述 */ #define MATH_ERRNO /* 参见描述 */ #define MATH_ERREXCEPT /* 参见描述 */ #define math_errhandling /* 参见描述 */ namespace std { /* 浮点类型 */ acos(/* 浮点类型 */ x); float acosf(float x); long double acosl(long double x); /* 浮点类型 */ asin(/* 浮点类型 */ x); float asinf(float x); long double asinl(long double x); /* 浮点类型 */ atan(/* 浮点类型 */ x); float atanf(float x); long double atanl(long double x); /* 浮点类型 */ atan2(/* 浮点类型 */ y, /* 浮点类型 */ x); float atan2f(float y, float x); long double atan2l(long double y, long double x); /* 浮点类型 */ cos(/* 浮点类型 */e x); float cosf(float x); long double cosl(long double x); /* 浮点类型 */ sin(/* 浮点类型 */ x); float sinf(float x); long double sinl(long double x); /* 浮点类型 */ tan(/* 浮点类型 */ x); float tanf(float x); long double tanl(long double x); /* 浮点类型 */ acosh(/* 浮点类型 */ x); float acoshf(float x); long double acoshl(long double x); /* 浮点类型 */ asinh(/* 浮点类型 */ x); float asinhf(float x); long double asinhl(long double x); /* 浮点类型 */ atanh(/* 浮点类型 */ x); float atanhf(float x); long double atanhl(long double x); /* 浮点类型 */ cosh(/* 浮点类型 */ x); float coshf(float x); long double coshl(long double x); /* 浮点类型 */ sinh(/* 浮点类型 */ x); float sinhf(float x); long double sinhl(long double x); /* 浮点类型 */ tanh(/* 浮点类型 */ x); float tanhf(float x); long double tanhl(long double x); /* 浮点类型 */ exp(/* 浮点类型 */ x); float expf(float x); long double expl(long double x); /* 浮点类型 */ exp2(/* 浮点类型 */ x); float exp2f(float x); long double exp2l(long double x); /* 浮点类型 */ expm1(/* 浮点类型 */ x); float expm1f(float x); long double expm1l(long double x); constexpr /* 浮点类型 */ frexp(/* 浮点类型 */ value, int* exp); constexpr float frexpf(float value, int* exp); constexpr long double frexpl(long double value, int* exp); constexpr int</