math.h
Overview
Related Modules:
Description:
Provides common math functions.
You can use the functions provided in this file to perform mathematical operations during development. The functions include trigonometric, inverse trigonometric, hyperbolic, inverse hyperbolic, rounding, exponential, logarithmic, and Bessel functions. When using these functions, pay attention to the value range of their input parameters.
Since:
1.0
Version:
1.0
Summary
Macros
NAN (0.0f/0.0f) |
|
INFINITY 1e5000f |
|
Indicates an error that occurs in floating-point operations. |
|
Indicates the error handling mechanism employed by math functions. |
|
FP_ILOGBNAN (-1-0x7fffffff) |
|
Indicates the calculation result of ilogb(0). |
|
FP_NAN 0 |
|
FP_ZERO 2 |
|
isinf(x) |
|
isnan(x) |
|
isnormal(x) |
Checks whether the floating-point value x is a normal value. |
isfinite(x) |
|
signbit(x) |
Checks whether the sign of the floating-point value x is negative. |
isunordered(x, y) (isnan((x)) ? ((void)(y),1) : isnan((y))) |
|
isless(x, y) tg_pred_2(x, y, isless) |
|
islessequal(x, y) tg_pred_2(x, y, islessequal) |
Checks whether floating-point value x is less than or equal to y. |
islessgreater(x, y) tg_pred_2(x, y, islessgreater) |
Checks whether floating-point value x is either less than or greater than y. |
isgreater(x, y) tg_pred_2(x, y, isgreater) |
|
isgreaterequal(x, y) tg_pred_2(x, y, isgreaterequal) |
Checks whether floating-point value x is greater than or equal to y. |
MAXFLOAT 3.40282346638528859812e+38F |
|
M_E 2.7182818284590452354 / e / |
|
M_LOG2E 1.4426950408889634074 / log_2 e / |
|
M_LOG10E 0.43429448190325182765 / log_10 e / |
|
M_LN2 0.69314718055994530942 / log_e 2 / |
|
M_LN10 2.30258509299404568402 / log_e 10 / |
|
M_PI 3.14159265358979323846 / pi / |
|
M_PI_2 1.57079632679489661923 / pi/2 / |
|
M_PI_4 0.78539816339744830962 / pi/4 / |
|
M_1_PI 0.31830988618379067154 / 1/pi / |
|
M_2_PI 0.63661977236758134308 / 2/pi / |
|
M_2_SQRTPI 1.12837916709551257390 / 2/sqrt(pi) / |
|
Functions
acos (double x) |
|
acosf (float x) |
|
acosl (long double x) |
|
acosh (double x) |
Calculates the inverse hyperbolic cosine of the double value x. |
acoshf (float x) |
|
acoshl (long double x) |
Calculates the inverse hyperbolic cosine of the long double value x. |
asin (double x) |
|
asinf (float x) |
|
asinl (long double x) |
|
asinh (double x) |
Calculates the inverse hyperbolic sine of the double value x. |
asinhf (float x) |
Calculates the inverse hyperbolic sine of the float value x. |
asinhl (long double x) |
Calculates the inverse hyperbolic sine of the long double value x. |
atan (double x) |
|
atanf (float x) |
|
atanl (long double x) |
|
atan2 (double y, double x) |
|
atan2f (float y, float x) |
|
atan2l (long double y, long double x) |
Calculates the arc tangent of two long double values x and y. |
atanh (double x) |
Calculates the inverse hyperbolic tangent of the double value x. |
atanhf (float x) |
Calculates the inverse hyperbolic tangent of the float value x. |
atanhl (long double x) |
Calculates the inverse hyperbolic tangent of the long double value x. |
cbrt (double x) |
|
cbrtf (float x) |
|
cbrtl (long double x) |
|
ceil (double x) |
Calculates the minimum integer greater than or equal to the double value x. |
ceilf (float x) |
Calculates the minimum integer greater than or equal to the float value x. |
ceill (long double x) |
Calculates the minimum integer greater than or equal to the long double value x. |
copysign (double x, double y) |
Generates a value by combining the magnitude of the double value x and the sign of the double value y. |
copysignf (float x, float y) |
Generates a value by combining the magnitude of the float value x and the sign of the float value y. |
copysignl (long double x, long double y) |
Generates a value by combining the magnitude of the long double value x and the sign of the long double value y. |
cos (double x) |
|
cosf (float x) |
|
cosl (long double x) |
|
cosh (double x) |
|
coshf (float x) |
|
coshl (long double x) |
Calculates the hyperbolic cosine of the long double value x. |
erf (double x) |
|
erff (float x) |
|
erfl (long double x) |
|
erfc (double x) |
Calculates the complementary error function of the double value x. |
erfcf (float x) |
Calculates the complementary error function of the float value x. |
erfcl (long double x) |
Calculates the complementary error function of the long double value x. |
exp (double x) |
Calculates the base-e exponential function of the double value x. |
expf (float x) |
Calculates the base-e exponential function of the float value x. |
expl (long double x) |
Calculates the base-e exponential function of the long double value x. |
exp2 (double x) |
Calculates the base-2 exponential function of the double value x. |
exp2f (float x) |
Calculates the base-2 exponential function of the float value x. |
exp2l (long double x) |
Calculates the base-2 exponential function of the long double value x. |
expm1 (double x) |
Calculates e raised to the power of the double value x minus one, that is, (e^x)-1. |
expm1f (float x) |
Calculates e raised to the power of the float value x minus one. |
expm1l (long double x) |
Calculates e raised to the power of the long double value x minus one. |
fabs (double x) |
|
fabsf (float x) |
|
fabsl (long double x) |
|
fdim (double x, double y) |
Calculates the positive difference between the double value x and y. |
fdimf (float x, float y) |
Calculates the positive difference between the float value x and y. |
fdiml (long double x, long double y) |
Calculates the positive difference between the long double value x and y. |
floor (double x) |
Obtains the largest integer less than or equal to the double value x. |
floorf (float x) |
Obtains the largest integer less than or equal to the float value x. |
floorl (long double x) |
Obtains the largest integer less than or equal to the long double value x. |
fma (double x, double y, double z) |
|
fmaf (float x, float y, float z) |
|
fmal (long double x, long double y, long double z) |
|
fmax (double x, double y) |
|
fmaxf (float x, float y) |
|
fmaxl (long double x, long double y) |
|
fmin (double x, double y) |
|
fminf (float x, float y) |
|
fminl (long double x, long double y) |
Obtains the smaller value of two long double values x and y. |
fmod (double x, double y) |
Calculates the remainder of the double value x divided by the double value y. |
fmodf (float x, float y) |
Calculates the remainder of the float value x divided by the float value y. |
fmodl (long double x, long double y) |
Calculates the remainder of the long double value x divided by the long double value y. |
Decomposes the double value x into a significand and an integral exponent for 2. |
|
Decomposes float value x into a binary significand and an integral exponent for 2. |
|
Decomposes long double value x into a binary significand and an integral exponent for 2. |
|
hypot (double x, double y) |
Calculates the hypotenuse of a right triangle whose legs are x and y. |
hypotf (float x, float y) |
Calculates the hypotenuse of a right triangle whose legs are x and y. |
hypotl (long double x, long double y) |
Calculates the hypotenuse of a right triangle whose legs are x and y. |
ilogb (double x) |
Obtains the integral part of the logarithm of double value x. |
ilogbf (float x) |
Obtains the integral part of the logarithm of float value x. |
ilogbl (long double x) |
Obtains the integral part of the logarithm of the long double value x. |
Multiplies the double value x by 2 raised to the power of exp. |
|
Multiplies the float value x by 2 raised to the power of exp. |
|
Multiplies the long double value x by 2 raised to the power of exp. |
|
lgamma (double x) |
Calculates the natural logarithm of the absolute value of the gamma function of the double value x. |
lgammaf (float x) |
Calculates the natural logarithm of the absolute value of the gamma function of the float value x. |
lgammal (long double x) |
Calculates the natural logarithm of the absolute value of the gamma function of the long double value x. |
llrint (double x) |
|
llrintf (float x) |
|
llrintl (long double x) |
|
llround (double x) |
Rounds double value x to the nearest integer, rounding away from 0. |
llroundf (float x) |
Rounds float value x to the nearest integer, rounding away from 0. |
llroundl (long double x) |
Rounds long double value x to the nearest integer, rounding away from 0. |
log (double x) |
|
logf (float x) |
|
logl (long double x) |
Calculates the natural logarithm of the long double value x. |
log10 (double x) |
Calculates the common logarithm (logarithm with base 10) of the double value x. |
log10f (float x) |
Calculates the common logarithm (logarithm with base 10) of the float value x. |
log10l (long double x) |
Calculates the common logarithm (logarithm with base 10) of the long double value x. |
log1p (double x) |
Calculates the natural logarithm of one plus the double value x. |
log1pf (float x) |
Calculates the natural logarithm of one plus the float value x. |
log1pl (long double x) |
Calculates the natural logarithm of one plus the long double value x. |
log2 (double x) |
Calculates the binary logarithm (logarithm with base 2) of the double value x. |
log2f (float x) |
Calculates the binary logarithm (logarithm with base 2) of the float value x. |
log2l (long double x) |
Calculates the binary logarithm (logarithm with base 2) of the long double value x. |
logb (double x) |
Calculates the logarithm of the absolute value of the double value x. |
logbf (float x) |
Calculates the logarithm of the absolute value of the float value x. |
logbl (long double x) |
Calculates the logarithm of the absolute value of the long double value x. |
lrint (double x) |
|
lrintf (float x) |
|
lrintl (long double x) |
|
lround (double x) |
Rounds double value x to the nearest integer, rounding away from 0. |
lroundf (float x) |
Rounds the float value x to the nearest integer, rounding away from 0. |
lroundl (long double x) |
Rounds the long double value x to the nearest integer, rounding away from 0. |
modf (double x, double iptr) |
Breaks the double value x into a signed integral and a fractional part. |
modff (float x, float iptr) |
Breaks the float value x into a signed integral and a fractional part. |
modfl (long double x, long double iptr) |
Breaks the long double value x into a signed integral and a fractional part. |
nan (const char tagp) |
|
nanf (const char tagp) |
|
nanl (const char tagp) |
|
nearbyint (double x) |
Rounds the double value x to an integer in floating-point format. |
nearbyintf (float x) |
Rounds the float value x to an integer in floating-point format. |
nearbyintl (long double x) |
Rounds the long double value x to an integer in floating-point format. |
nextafter (double x, double y) |
Obtains the next representable value following the double value x in the direction of the double value y. |
nextafterf (float x, float y) |
Obtains the next representable value following the float value x in the direction of the float value y. |
nextafterl (long double x, long double y) |
Obtains the next representable value following the long double value x in the direction of the long double value y. |
nexttoward (double x, long double y) |
Obtains the next representable value following the double value x in the direction of the long double value y. |
nexttowardf (float x, long double y) |
Obtains the next representable value following the float value x in the direction of the long double value y. |
nexttowardl (long double x, long double y) |
Obtains the next representable value following the long double value x in the direction of the long double value y. |
pow (double x, double y) |
Obtains the double value x raised to the power of the double value y. |
powf (float x, float y) |
Obtains the float value x raised to the power of the float value y. |
powf10 (float x) |
|
powl (long double x, long double y) |
Obtains the long double value x raised to the power of the long double value y. |
powl10 (long double x) |
|
remainder (double x, double y) |
Calculates the remainder of the double value x divided by the double value y. |
remainderf (float x, float y) |
Calculates the remainder of the float value x divided by the float value y. |
remainderl (long double x, long double y) |
Calculates the remainder of the long double value x divided by the long double value y. |
remquo (double x, double y, int quo) |
Calculates the quotient and remainder of the double value x divided by the double value y. |
remquof (float x, float y, int quo) |
Calculates the quotient and remainder of the float value x divided by the float value y. |
remquol (long double x, long double y, int quo) |
Calculates the quotient and remainder of the long double value x divided by the long double value y. |
rint (double x) |
|
rintf (float x) |
|
rintl (long double x) |
|
round (double x) |
Rounds the double value x to the nearest integer, rounding away from 0. |
roundf (float x) |
Rounds the float value x to the nearest integer, rounding away from 0. |
roundl (long double x) |
Rounds the long double value x to the nearest integer, rounding away from 0. |
Multiplies the double value x by FLT_RADIX raised to the power of the long int value exp, that is, x(FLT_RADIX)^exp. |
|
Multiplies the float value x by FLT_RADIX raised to the power of the long int value exp, that is, x(FLT_RADIX)^exp. |
|
Multiplies the long double value x by FLT_RADIX raised to the power of the long int value exp, that is, x(FLT_RADIX)^exp. |
|
Multiplies the double value x by FLT_RADIX raised to the power of the int value exp, that is, x(FLT_RADIX)^exp. |
|
Multiplies the float value x by FLT_RADIX raised to the power of the int value exp, that is, x(FLT_RADIX)^exp. |
|
Multiplies the long double value x by FLT_RADIX raised to the power of the int value exp, that is, x(FLT_RADIX)^exp. |
|
sin (double x) |
|
sinf (float x) |
|
sinl (long double x) |
|
sinh (double x) |
|
sinhf (float x) |
|
sinhl (long double x) |
|
sqrt (double x) |
|
sqrtf (float x) |
|
sqrtl (long double x) |
|
tan (double x) |
|
tanf (float x) |
|
tanl (long double x) |
|
tanh (double x) |
|
tanhf (float x) |
|
tanhl (long double x) |
Calculates the hyperbolic tangent of the long double value x. |
tgamma (double x) |
|
tgammaf (float x) |
|
tgammal (long double x) |
|
trunc (double x) |
Obtains the nearest integer whose absolute value is less than or equal to the absolute value of the double value x. |
truncf (float x) |
Obtains the nearest integer whose absolute value is less than or equal to the absolute value of the float value x. |
truncl (long double x) |
Obtains the nearest integer whose absolute value is less than or equal to the absolute value of the long double value x. |
j0 (double x) |
Calculates the Bessel function of the first kind of order 0 for the double value x. |
j1 (double x) |
Calculates the Bessel function of the first kind of order 1 for the double value x. |
jn (int n, double x) |
Calculates the Bessel function of the first kind of order n for the double value x. |
y0 (double x) |
Calculates the Bessel function of the second kind of order 0 for the double value x. |
y1 (double x) |
Calculates the Bessel function of the second kind of order 1 for the double value x. |
yn (int n, double x) |
Calculates the Bessel function of the second kind of order n for the double value x. |
finite (double x) |
Checks whether the double value x is an infinity or a NaN value. |
finitef (float x) |
Checks whether the float value x is an infinity or a NaN value. |
Multiplies the double value x by FLT_RADIX raised to the power of the double value exp, that is, xFLT_RADIX^exp. |
|
Multiplies the float value x by FLT_RADIX raised to the power of the float value exp, that is, xFLT_RADIX^exp. |
|
significand (double x) |
Obtains the significand of the double value x scaled to the range [1,2). |
significandf (float x) |
Obtains the significand of the float value x scaled to the range [1,2). |
j0f (float x) |
Calculates the Bessel function of the first kind of order 0 for the float value x. |
j1f (float x) |
Calculates the Bessel function of the first kind of order 1 for the float value x. |
jnf (int n, float x) |
Calculates the Bessel function of the first kind of order n for the float value x. |
y0f (float x) |
Calculates the Bessel function of the second kind of order 0 for the float value x. |
y1f (float x) |
Calculates the Bessel function of the second kind of order 1 for the float value x. |
ynf (int n, float x) |
Calculates the Bessel function of the second kind of order n for the float value x. |
lgammal_r (long double x, int signp) |
Calculates the natural logarithm of the absolute value of the gamma function of the double value x. |
exp10 (double x) |
Calculates the base-10 exponential function of the double value x. |
exp10f (float x) |
Calculates the base-10 exponential function of the float value x. |
exp10l (long double x) |
Calculates the base-10 exponential function of the long double value x. |
pow10 (double x) |
Calculates the value of 10 raised to the power x, which is a double value. |
pow10f (float x) |
Calculates the value of 10 raised to the power x, which is a float value. |
pow10l (long double x) |
Calculates the value of 10 raised to the power x, which is a long double value. |