Mathematical constants and functions.
More...
Go to the source code of this file.
|
#define | abs(a) (((a) < 0) ? -(a) : (a)) |
| The absolute value.
|
|
#define | max(a, b) (((a) > (b)) ? (a) : (b)) |
| The max of the two values.
|
|
#define | min(a, b) (((a) < (b)) ? (a) : (b)) |
| The min of the two values.
|
|
#define | sign(x) ((x < 0) ? -1 : ((x > 0) ? 1 : 0)) |
| The sign the the passed value.
|
|
#define | round_up(number, base) (((number) + (base)-1) & ~((base)-1)) |
| Returns a rounded up, away from zero, to the nearest multiple of b.
|
|
#define | M_E 2.7182818284590452354 |
| e
|
|
#define | M_LOG2E 1.4426950408889634074 |
| log_2 e
|
|
#define | M_LOG10E 0.43429448190325182765 |
| log_10 e
|
|
#define | M_LN2 0.69314718055994530942 |
| log_e 2
|
|
#define | M_LN10 2.30258509299404568402 |
| log_e 10
|
|
#define | M_PI 3.14159265358979323846 |
| pi
|
|
#define | M_PI_2 1.57079632679489661923 |
| pi / 2
|
|
#define | M_PI_4 0.78539816339744830962 |
| pi / 4
|
|
#define | M_1_PI 0.31830988618379067154 |
| 1 / pi
|
|
#define | M_2_PI 0.63661977236758134308 |
| 2 / pi
|
|
#define | M_2_SQRTPI 1.12837916709551257390 |
| 2 / sqrt(pi)
|
|
#define | M_SQRT2 1.41421356237309504880 |
| sqrt(2)
|
|
#define | M_SQRT1_2 0.70710678118654752440 |
| 1 / sqrt(2)
|
|
|
double | round (double x) |
| Returns the integral value that is nearest to x, with halfway cases rounded away from zero. More...
|
|
double | ceil (double x) |
| Rounds x upward, returning the smallest integral value that is not less than x. More...
|
|
double | floor (double x) |
| Rounds x downward, returning the largest integral value that is not greater than x. More...
|
|
double | pow (double base, double exponent) |
| Returns base raised to the power exponent: More...
|
|
double | exp (double x) |
| Returns the base-e exponential function of x, which is e raised to the power x: e^x. More...
|
|
double | fabs (double x) |
| Returns the absolute value of x: |x|. More...
|
|
float | fabsf (float x) |
| Returns the absolute value of x: |x|. More...
|
|
double | sqrt (double x) |
| Returns the square root of x. More...
|
|
float | sqrtf (float x) |
| Returns the square root of x. More...
|
|
int | isinf (double x) |
| Checks if the input value is Infinite (INF). More...
|
|
int | isnan (double x) |
| Checks if the input value is Not A Number (NAN). More...
|
|
double | log10 (double x) |
| Logarithm function in base 10. More...
|
|
double | ln (double x) |
| Natural logarithm function. More...
|
|
double | logx (double x, double y) |
| Logarithm function in base x. More...
|
|
double | modf (double x, double *intpart) |
| Breaks x into an integral and a fractional part, both parts have the same sign as x. More...
|
|
Mathematical constants and functions.
- Copyright
- (c) 2014-2024 This file is distributed under the MIT License. See LICENSE.md for details.
◆ ceil()
Rounds x upward, returning the smallest integral value that is not less than x.
- Parameters
-
- Returns
- The smallest integral value that is not less than x (as a floating-point value).
◆ exp()
Returns the base-e exponential function of x, which is e raised to the power x: e^x.
- Parameters
-
- Returns
- Exponential value of x.
If the magnitude of the result is too large to be represented by a value of the return type, the function returns HUGE_VAL (or HUGE_VALF or HUGE_VALL) with the proper sign, and an overflow range error occurs and the global variable errno is set to ERANGE.
◆ fabs()
Returns the absolute value of x: |x|.
- Parameters
-
x | Value whose absolute value is returned. |
- Returns
- The absolute value of x.
◆ fabsf()
Returns the absolute value of x: |x|.
- Parameters
-
x | Value whose absolute value is returned. |
- Returns
- The absolute value of x.
◆ floor()
Rounds x downward, returning the largest integral value that is not greater than x.
- Parameters
-
- Returns
- The value of x rounded downward (as a floating-point value).
◆ isinf()
Checks if the input value is Infinite (INF).
- Parameters
-
- Returns
- 1 if INF, 0 otherwise.
◆ isnan()
Checks if the input value is Not A Number (NAN).
- Parameters
-
- Returns
- 1 if NAN, 0 otherwise.
◆ ln()
Natural logarithm function.
- Parameters
-
x | Topic of the logarithm function. |
- Returns
- Return the result.
◆ log10()
Logarithm function in base 10.
- Parameters
-
x | Topic of the logarithm function. |
- Returns
- Return the result.
◆ logx()
double logx |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
Logarithm function in base x.
- Parameters
-
x | Base of the logarithm. |
y | Topic of the logarithm function. |
- Returns
- Return the result.
◆ modf()
double modf |
( |
double |
x, |
|
|
double * |
intpart |
|
) |
| |
Breaks x into an integral and a fractional part, both parts have the same sign as x.
- Parameters
-
x | The value we want to break. |
intpart | Where we store the integer part. |
- Returns
- the fractional part.
◆ pow()
double pow |
( |
double |
base, |
|
|
double |
exponent |
|
) |
| |
Returns base raised to the power exponent:
- Parameters
-
base | Base value. |
exponent | Exponent value. |
- Returns
- The result of raising base to the power exponent.
If the base is finite negative and the exponent is finite but not an integer value, it causes a domain error. If both base and exponent are zero, it may also cause a domain error on certain implementations. If base is zero and exponent is negative, it may cause a domain error or a pole error (or none, depending on the library implementation). The function may also cause a range error if the result is too great or too small to be represented by a value of the return type.
◆ round()
Returns the integral value that is nearest to x, with halfway cases rounded away from zero.
- Parameters
-
- Returns
- The value of x rounded to the nearest integral (as a floating-point value).
◆ sqrt()
Returns the square root of x.
- Parameters
-
x | Value whose square root is computed. |
- Returns
- Square root of x. If x is negative, the global variable errno is set to EDOM.
◆ sqrtf()
Returns the square root of x.
- Parameters
-
x | Value whose square root is computed. |
- Returns
- Square root of x. If x is negative, the global variable errno is set to EDOM.