avr_math(3)
π avr_math π
okay bestie, sit DOWN, because this is the avr_math(3) page from avr-libc and it is genuinely the math-girlie of the AVR world. every constant you ever needed for your trig homework AND your embedded project, all chilling in one header. no cap.
β¨ NAME β¨
avr_math β the header that hands you all the basic math constants and functions for avr-libc, and yes it's as iconic as it sounds π
πΈ SYNOPSIS πΈ
π« Macros π«
#define M_E 2.7182818284590452354
#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) */
#define NAN __builtin_nan('')
#define INFINITY __builtin_inf()
#define __ASM_ALIAS(x) __asm(#x)
π§ Functions π§
float cosf (float __x)
double cos (double __x) __ASM_ALIAS(cosf)
float sinf (float __x)
double sin (double __x) __ASM_ALIAS(sinf)
float tanf (float __x)
double tan (double __x) __ASM_ALIAS(tanf)
static float fabsf (float __x)
static double fabs (double __x)
float fmodf (float __x, float __y)
double fmod (double __x, double __y) __ASM_ALIAS(fmodf)
float modff (float __x, float *__iptr)
double modf (double __x, double *__iptr) __ASM_ALIAS(modff)
float sqrtf (float __x)
double sqrt (double __x) __ASM_ALIAS(sqrtf)
float cbrtf (float __x)
double cbrt (double __x) __ASM_ALIAS(cbrtf)
float hypotf (float __x, float __y)
double hypot (double __x, double __y) __ASM_ALIAS(hypotf)
float squaref (float __x)
double square (double __x) __ASM_ALIAS(squaref)
float floorf (float __x)
double floor (double __x) __ASM_ALIAS(floorf)
float ceilf (float __x)
double ceil (double __x) __ASM_ALIAS(ceilf)
float frexpf (float __x, int *__pexp)
double frexp (double __x, int *__pexp) __ASM_ALIAS(frexpf)
float ldexpf (float __x, int __exp)
double ldexp (double __x, int __exp) __ASM_ALIAS(ldexpf)
float expf (float __x)
double exp (double __x) __ASM_ALIAS(expf)
float coshf (float __x)
double cosh (double __x) __ASM_ALIAS(coshf)
float sinhf (float __x)
double sinh (double __x) __ASM_ALIAS(sinhf)
float tanhf (float __x)
double tanh (double __x) __ASM_ALIAS(tanhf)
float acosf (float __x)
double acos (double __x) __ASM_ALIAS(acosf)
float asinf (float __x)
double asin (double __x) __ASM_ALIAS(asinf)
float atanf (float __x)
double atan (double __x) __ASM_ALIAS(atanf)
float atan2f (float __y, float __x)
double atan2 (double __y, double __x) __ASM_ALIAS(atan2f)
float logf (float __x)
double log (double __x) __ASM_ALIAS(logf)
float log10f (float __x)
double log10 (double __x) __ASM_ALIAS(log10f)
float powf (float __x, float __y)
double pow (double __x, double __y) __ASM_ALIAS(powf)
int isnanf (float __x)
int isnan (double __x) __ASM_ALIAS(isnanf)
int isinff (float __x)
int isinf (double __x) __ASM_ALIAS(isinff)
static int isfinitef (float __x)
static int isfinite (double __x)
static float copysignf (float __x, float __y)
static double copysign (double __x, double __y)
int signbitf (float __x)
int signbit (double __x) __ASM_ALIAS(signbitf)
float fdimf (float __x, float __y)
double fdim (double __x, double __y) __ASM_ALIAS(fdimf)
float fmaf (float __x, float __y, float __z)
double fma (double __x, double __y, double __z) __ASM_ALIAS(fmaf)
float fmaxf (float __x, float __y)
double fmax (double __x, double __y) __ASM_ALIAS(fmaxf)
float fminf (float __x, float __y)
double fmin (double __x, double __y) __ASM_ALIAS(fminf)
float truncf (float __x)
double trunc (double __x) __ASM_ALIAS(truncf)
float roundf (float __x)
double round (double __x) __ASM_ALIAS(roundf)
long lroundf (float __x)
long lround (double __x) __ASM_ALIAS(lroundf)
long lrintf (float __x)
long lrint (double __x) __ASM_ALIAS(lrintf)
likeβ¦ look at that list. she's THOROUGH. every double version is just vibing off its float sibling through __ASM_ALIAS, which is giving "same energy, different name" β¨
π Detailed Description π
#include <math.h>
This header file declares basic mathematics constants and functions. that's it, that's the whole personality π
Notes:
- bestie, listen β to actually access the functions declared in here, you're usually gonna have to also link against the library
libm.a. like, they're declared, they're cute, but they need their support system. there's a related FAQ entry about it too, iykyk. - math functions do not raise exceptions and do not change the
errnovariable. because of that, the majority of them are declared with theconstattribute, so GCC can optimize them better. lowkey a flex π₯
π Macro Definition Documentation π
π #define INFINITY __builtin_inf()
the INFINITY constant. yes she's real, yes she goes on forever, periodt.
π #define M_1_PI 0.31830988618379067154 /* 1/pi */
the constant 1/pi.
π #define M_2_PI 0.63661977236758134308 /* 2/pi */
the constant 2/pi.
π #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
the constant 2/sqrt(pi).
π #define M_E 2.7182818284590452354
the constant e. the original main character of logarithms, we stan π
π #define M_LN10 2.30258509299404568402 /* log_e 10 */
the natural logarithm of the 10. (yes, the original page really says "of the 10", and honestly? iconic phrasing, keeping it π)
π #define M_LN2 0.69314718055994530942 /* log_e 2 */
the natural logarithm of the 2.
π #define M_LOG10E 0.43429448190325182765 /* log_10 e */
the logarithm of the e to base 10.
π #define M_LOG2E 1.4426950408889634074 /* log_2 e */
the logarithm of the e to base 2.
π #define M_PI 3.14159265358979323846 /* pi */
the constant pi. the moment. the icon. the legend π
π #define M_PI_2 1.57079632679489661923 /* pi/2 */
the constant pi/2.
π #define M_PI_4 0.78539816339744830962 /* pi/4 */
the constant pi/4.
π #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
the constant 1/sqrt(2).
π #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
the square root of 2. she's irrational and she's thriving π¦
π #define NAN __builtin_nan('')
the NAN constant. not a number, but somehow still has main character energy π
okay so that's the constants and the declarations handled, but there is so much more coming β the actual function documentation is next and it's a whole journey, so don't go anywhere bestie π
π Function Documentation π
double acos (double __x)
The alias for acosf(). π
float acosf (float __x)
The acosf() function computes the principal value of the arc cosine of __x. The returned value is in the range [0, pi] radians. A domain error occurs for arguments not in the range [-1, +1]. π
double asin (double __x)
The alias for asinf(). β¨
float asinf (float __x)
The asinf() function computes the principal value of the arc sine of __x. The returned value is in the range [-pi/2, pi/2] radians. A domain error occurs for arguments not in the range [-1, +1]. π¦
double atan (double __x)
The alias for atanf(). π
double atan2 (double __y, double __x)
The alias for atan2f(). πΈ
float atan2f (float __y, float __x)
The atan2f() function computes the principal value of the arc tangent of __y / __x, using the signs of both arguments to determine the quadrant of the return value. The returned value is in the range [-pi, +pi] radians. π
float atanf (float __x)
The atanf() function computes the principal value of the arc tangent of __x. The returned value is in the range [-pi/2, pi/2] radians. β
double cbrt (double __x)
The alias for cbrtf(). π
float cbrtf (float __x)
The cbrt() function returns the cube root of __x. π
double ceil (double __x)
The alias for ceilf(). β¨
float ceilf (float __x)
The ceilf() function returns the smallest integral value greater than or equal to __x, expressed as a floating-point number. π
static float copysignf (float __x, float __y) [static]
The copysignf() function returns __x but with the sign of __y. They work even if __x or __y are NaN or zero. π¦
double cos (double __x)
The alias for cosf(). π
float cosf (float __x)
The cosf() function returns the cosine of __x, measured in radians. πΈ
double cosh (double __x)
The alias for coshf(). π
float coshf (float __x)
The coshf() function returns the hyperbolic cosine of __x. β
double exp (double __x)
The alias for expf(). π
float expf (float __x)
The expf() function returns the exponential value of __x. π
static float fabsf (float __x) [static]
The fabsf() function computes the absolute value of a floating-point number __x. β¨
double fdim (double __x, double __y)
The alias for fdimf(). π
float fdimf (float __x, float __y)
The fdimf() function returns maxf(__x - __y, 0). If __x or __y or both are NaN, NaN is returned. π¦
double floor (double __x)
The alias for floorf(). π
float floorf (float __x)
The floorf() function returns the largest integral value less than or equal to __x, expressed as a floating-point number. πΈ
double fma (double __x, double __y, double __z)
The alias for fmaf(). π
float fmaf (float __x, float __y, float __z)
The fmaf() function performs floating-point multiply-add. This is the operation (__x * __y) + __z, but the intermediate result is not rounded to the destination type. This can sometimes improve the precision of a calculation. β
double fmax (double __x, double __y)
The alias for fmaxf(). π
float fmaxf (float __x, float __y)
The fmaxf() function returns the greater of the two values __x and __y. If an argument is NaN, the other argument is returned. If both arguments are NaN, NaN is returned. π
double fmin (double __x, double __y)
The alias for fminf(). β¨
float fminf (float __x, float __y)
The fminf() function returns the lesser of the two values __x and __y. If an argument is NaN, the other argument is returned. If both arguments are NaN, NaN is returned. π
double fmod (double __x, double __y)
The alias for fmodf(). π¦
float fmodf (float __x, float __y)
The function fmodf() returns the floating-point remainder of __x / __y. π
double frexp (double __x, int * __pexp)
The alias for frexpf(). πΈ
float frexpf (float __x, int * __pexp)
The frexpf() function breaks a floating-point number into a normalized fraction and an integral power of 2. It stores the integer in the int object pointed to by __pexp.
If __x is a normal float point number, the frexpf() function returns the value v, such that v has a magnitude in the interval [1/2, 1) or zero, and __x equals v times 2 raised to the power __pexp. If __x is zero, both parts of the result are zero. If __x is not a finite number, the frexpf() returns __x as is and stores 0 by __pexp.
Note: This implementation permits a zero pointer as a directive to skip a storing the exponent. π
double hypot (double __x, double __y)
The alias for hypotf(). β
float hypotf (float __x, float __y)
The hypotf() function returns sqrtf(__x*__x + __y*__y). This is the length of the hypotenuse of a right triangle with sides of length __x and __y, or the distance of the point (__x, __y) from the origin. Using this function instead of the direct formula is wise, since the error is much smaller. No underflow with small __x and __y. No overflow if result is in range. π
static int isfinite (double __x) [static]
Parameters:
__xβ The alias forisfinitef(). π
static int isfinitef (float __x) [static]
The isfinitef() function returns a nonzero value if __x is finite: not plus or minus infinity, and not NaN. β¨
int isinf (double __x)
The alias for isinff(). π
int isinff (float __x)
The function isinff() returns 1 if the argument __x is positive infinity, -1 if __x is negative infinity, and 0 otherwise.
Note: The GCC 4.3 can replace this function with inline code that returns the 1 value for both infinities (gcc bug #35509). π¦
int isnan (double __x)
The alias for isnanf(). π
int isnanf (float __x)
The function isnanf() returns 1 if the argument __x represents a 'not-a-number' (NaN) object, otherwise 0. πΈ
double ldexp (double __x, int __exp)
The alias for ldexpf(). π
float ldexpf (float __x, int __exp)
The ldexpf() function multiplies a floating-point number by an integral power of 2. It returns the value of __x times 2 raised to the power __exp. β
double log (double __x)
The alias for logf(). π
double log10 (double __x)
The alias for log10f(). π
float log10f (float __x)
The log10f() function returns the logarithm of argument __x to base 10. β¨
float logf (float __x)
The logf() function returns the natural logarithm of argument __x. π
long lrint (double __x)
The alias for lrintf(). π¦
long lrintf (float __x)
The lrintf() function rounds __x to the nearest integer, rounding the halfway cases to the even integer direction. (That is both 1.5 and 2.5 values are rounded to 2). This function is similar to rintf() function, but it differs in type of return value and in that an overflow is possible.
Returns:
- The rounded
longinteger value. If__xis not a finite number or an overflow was, this realization returns theLONG_MINvalue (0x80000000). π
long lround (double __x)
The alias for lroundf(). πΈ
long lroundf (float __x)
The lroundf() function rounds __x to the nearest integer, but rounds halfway cases away from zero (instead of to the nearest even integer). This function is similar to roundf() function, but it differs in type of return value and in that an overflow is possible.
Returns:
- The rounded
longinteger value. If__xis not a finite number or an overflow was, this realization returns theLONG_MINvalue (0x80000000). π
double modf (double __x, double * __iptr)
An alias for modff(). β
float modff (float __x, float * __iptr)
The modff() function breaks the argument __x into integral and fractional parts, each of which has the same sign as the argument. It stores the integral part as a double in the object pointed to by __iptr.
The modff() function returns the signed fractional part of __x.
Note: This implementation skips writing by zero pointer. However, the GCC 4.3 can replace this function with inline code that does not permit to use NULL address for the avoiding of storing. π
double pow (double __x, double __y)
The alias for powf(). π
float powf (float __x, float __y)
The function powf() returns the value of __x to the exponent __y. β¨
double round (double __x)
The alias for roundf(). π
float roundf (float __x)
The roundf() function rounds __x to the nearest integer, but rounds halfway cases away from zero (instead of to the nearest even integer). Overflow is impossible.
Returns:
- The rounded value. If
__xis an integral or infinite,__xitself is returned. If__xis NaN, then NaN is returned. π¦
int signbit (double __x)
The alias for signbitf(). π
int signbitf (float __x)
The signbitf() function returns a nonzero value if the value of __x has its sign bit set. This is not the same as __x < 0.0, because IEEE 754 floating point allows zero to be signed. The comparison -0.0 < 0.0 is false, but signbit (-0.0) will return a nonzero value. πΈ
double sin (double __x)
The alias for sinf(). π
float sinf (float __x)
The sinf() function returns the sine of __x, measured in radians. β
double sinh (double __x)
The alias for sinhf(). π
float sinhf (float __x)
The sinhf() function returns the hyperbolic sine of __x. π
double sqrt (double __x)
An alias for sqrtf(). β¨
float sqrtf (float __x)
The sqrtf() function returns the non-negative square root of __x. π
double square (double __x)
The alias for squaref(). π¦
float squaref (float __x)
The function squaref() returns __x * __x.
Note: This function does not belong to the C standard definition. π
double tan (double __x)
The alias for tanf(). πΈ
float tanf (float __x)
The tanf() function returns the tangent of __x, measured in radians. π
double tanh (double __x)
The alias for tanhf(). β
float tanhf (float __x)
The tanhf() function returns the hyperbolic tangent of __x. π
double trunc (double __x)
The alias for truncf(). π
float truncf (float __x)
The truncf() function rounds __x to the nearest integer not larger in absolute value. β¨
π Author π
Generated automatically by Doxygen for avr-libc from the source code. π
That's the whole vibe, bestie. This was avr-libc version 2.1.0, dated Sat Jan 29 2022, from the avr_math(3) manual. Catch u later, stay iconic! π
β¨
π¦ where this page comes from
- fedora 43: avr-libc 2.2.1-3.fc43 Β· BSD-3-Clause
- fedora 44: avr-libc 2.2.1-5.fc44 Β· BSD-3-Clause
- opensuse-leap 16.0: avr-libc 2.1.0-bp160.1.33 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms