AVR Libc Home Page |  | AVR Libc Development Pages
Main Page | User Manual | Library Reference | FAQ | Alphabetical Index | Example Projects

# <math.h>: Mathematics

## Detailed Description

     #include <math.h>

This header file declares basic mathematics constants and functions.

Note:
  In order to access the functions delcared herein, it is usually also required to additionally link against the library `libm.a`. See also the related FAQ entry.

## Defines

#define | M_PI 3.141592653589793238462643
#define | M_SQRT2 1.4142135623730950488016887
#define | NAN __builtin_nan("")
#define | INFINITY __builtin_inf()

## Functions

double | cos (double __x) __ATTR_CONST__
double | fabs (double __x) __ATTR_CONST__
double | fmod (double __x, double __y) __ATTR_CONST__
double | modf (double __value, double *__iptr)
double | sin (double __x) __ATTR_CONST__
double | sqrt (double __x) __ATTR_CONST__
double | tan (double __x) __ATTR_CONST__
double | floor (double __x) __ATTR_CONST__
double | ceil (double __x) __ATTR_CONST__
double | frexp (double __value, int *__exp)
double | ldexp (double __x, int __exp) __ATTR_CONST__
double | exp (double __x) __ATTR_CONST__
double | cosh (double __x) __ATTR_CONST__
double | sinh (double __x) __ATTR_CONST__
double | tanh (double __x) __ATTR_CONST__
double | acos (double __x) __ATTR_CONST__
double | asin (double __x) __ATTR_CONST__
double | atan (double __x) __ATTR_CONST__
double | atan2 (double __y, double __x) __ATTR_CONST__
double | log (double __x) __ATTR_CONST__
double | log10 (double __x) __ATTR_CONST__
double | pow (double __x, double __y) __ATTR_CONST__
int | isnan (double __x) __ATTR_CONST__
int | isinf (double __x) __ATTR_CONST__
double | square (double __x) __ATTR_CONST__
__ATTR_CONST__ double | copysign (double x, double y)
double | fdim (double x, double y) __ATTR_CONST__
double | fma (double x, double y, double z) __ATTR_CONST__
double | fmax (double x, double y) __ATTR_CONST__
double | fmin (double x, double y) __ATTR_CONST__
int | signbit (double x) __ATTR_CONST__
double | trunc (double x) __ATTR_CONST__
__ATTR_CONST__ int | isfinite (double x)
double | hypot (double x, double y)

## Define Documentation

#define INFINITY __builtin_inf()

INFINITY constant.

#define M_PI 3.141592653589793238462643

The constant `pi`.

#define M_SQRT2 1.4142135623730950488016887

The square root of 2.

#define NAN __builtin_nan("")

NAN constant.

## Function Documentation

double acos | ( | double | __x | ) |

The acos() 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 asin() 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 atan() function computes the principal value of the arc tangent 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 atan2 | ( | double | __y,
|  | double | __x |
| ) |  |  |

The atan2() 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.

double ceil | ( | double | __x | ) |

The ceil() function returns the smallest integral value greater than or equal to `x`, expressed as a floating-point number.

__ATTR_CONST__ double copysign | ( | double | x,
|  | double | y |
| ) |  |  |

The copysign() 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 cos() function returns the cosine of `x`, measured in radians.

double cosh | ( | double | __x | ) |

The cosh() function returns the hyperbolic cosine of `x`.

double exp | ( | double | __x | ) |

The exp() function returns the exponential value of `x`.

double fabs | ( | double | __x | ) |

The fabs() function computes the absolute value of a floating-point number `x`.

double fdim | ( | double | x,
|  | double | y |
| ) |  |  |

The fdim() function returns `max(x-y,0)`. If `x` or `y` or both are NaN, NaN is returned.

double floor | ( | double | __x | ) |

The floor() 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 fma() 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 fmax() 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 fmin() 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 function fmod() returns the floating-point remainder of `x / y`.

double frexp | ( | double | __value,
|  | int * | __exp |
| ) |  |  |

The frexp() 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 `exp`.

The frexp() function returns the value `x`, such that `x` is a double with magnitude in the interval [1/2, 1) or zero, and `value` equals `x` times 2 raised to the power `*exp`. If value is zero, both parts of the result are zero.

double hypot | ( | double | x,
|  | double | y |
| ) |  |  |

The hypot() function returns 'sqrt (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.

__ATTR_CONST__ int isfinite | ( | double | x | ) |

The isfinite() function returns a nonzero value if `x` is finite: not plus or minus infinity, and not NaN.

int isinf | ( | double | __x | ) |

The function isinf() returns 1 if the argument `x` is either positive or negative infinity, otherwise 0.

int isnan | ( | double | __x | ) |

The function isnan() returns 1 if the argument `x` represents a "not-a-number" (NaN) object, otherwise 0.

double ldexp | ( | double | __x,
|  | int | __exp |
| ) |  |  |

The ldexp() function multiplies a floating-point number by an integral power of 2.

The ldexp() function returns the value of `x` times 2 raised to the power `exp`.

double log | ( | double | __x | ) |

The log() function returns the natural logarithm of argument `x`.

If the argument is less than or equal 0, a domain error will occur.

double log10 | ( | double | __x | ) |

The log10() function returns the logarithm of argument `x` to base 10.

If the argument is less than or equal 0, a domain error will occur.

double modf | ( | double | __value,
|  | double * | __iptr |
| ) |  |  |

The modf() function breaks the argument `value` 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 modf() function returns the signed fractional part of `value`.

Note:
  This implementation skips writing by zero pointer.

double pow | ( | double | __x,
|  | double | __y |
| ) |  |  |

The function pow() returns the value of `x` to the exponent `y`.

int signbit | ( | double | x | ) |

The signbit() 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.

Note:
  This implementation returns -1 if sign bit is set.

double sin | ( | double | __x | ) |

The sin() function returns the sine of `x`, measured in radians.

double sinh | ( | double | __x | ) |

The sinh() function returns the hyperbolic sine of `x`.

double sqrt | ( | double | __x | ) |

The sqrt() function returns the non-negative square root of `x`.

double square | ( | double | __x | ) |

The function square() returns `x * x`.

Note:
  This function does not belong to the C standard definition.

double tan | ( | double | __x | ) |

The tan() function returns the tangent of `x`, measured in radians.

double tanh | ( | double | __x | ) |

The tanh() function returns the hyperbolic tangent of `x`.

double trunc | ( | double | x | ) |

The trunc() function rounds `x` to the nearest integer not larger in absolute value.

Automatically generated by Doxygen 1.5.2 on 14 Feb 2008.