The following functions, macros, and classes are provided in math.h:
Name |
Description |
Header File math.h Description Overflow value for math functions. | |
Header File math.h Description The constant values for logarithm functions. | |
Header File math.h Description Constant values for square roots of 2. | |
Header File math.h Description Common constants of pi | |
Header File stdlib.h, math.h Category Conversion Routines, Math Routines Prototype double atof(const char *s); double _wtof(const wchar_t *s); Description Converts a string to a floating-point number.
| |
Header File math.h Category Conversion Routines, Math Routines Prototype long double _atold(const char *s); long double _wtold(const wchar_t *s); Description Converts a string to a long double. _wtold is the wide-character version. It converts a wide-character string to a long double. _atof is the floating-point version of _atold. _atold converts a string pointed to by s to a long double; this functions recognizes: An optional string of tabs and spaces An optional sign A string of digits and an optional decimal point An optional e or E followed by an optional signed integer The first unrecognized character ends the... more | |
Header File math.h, stdlib.h Category Conversion Routines, Math Routines, Prototype char *_i64toa(__int64 value, char *string, int radix); wchar_t *_i64tow(__int64 value, wchar_t *string, int radix); Description _i64toa converts an __int64 to a string. _i64tow is the unicode version. It converts a __int64 to a wide-character string. These functions convert value to a null-terminated string and store the result in string. value is an __int64. radix specifies the base to be used in converting value; it must be between 2 and 36, inclusive. If value is negative and radix is 10, the first character of string is the minus sign (... more | |
Header File math.h Category Diagnostic Routines, Math Routines Prototype int _matherr(struct _exception *e); int _matherrl(struct _exceptionl *e); Description User-modifiable math error handler. _matherr is called when an error is generated by the math library. _matherrl is the long double version; it is called when an error is generated by the long double math functions. _matherr and _matherrl each serve as a user hook (a function that can be customized by the user) that you can replace by writing your own math error-handling routine. _matherr and _matherrl are useful for information on trapping domain and range errors caused by the math... more | |
Header File stdlib.h, math.h Category Math Routines, Inline Routines Prototype int abs(int x); Description Returns the absolute value of an integer. abs returns the absolute value of the integer argument x. If abs is called when stdlib.h has been included, it's treated as a macro that expands to inline code. If you want to use the abs function instead of the macro, include #undef abs in your program, after the #include <stdlib.h>. Return Value The abs function returns an integer in the range of 0 to INT_MAX, with the exception that an argument with the value INT_MIN is returned as... more | |
Header File math.h Category Math Routines Prototype double acos(double x); long double acosl(long double x); Description Calculates the arc cosine. acos returns the arc cosine of the input value. acosl is the long double version; it takes a long double argument and returns a long double result. Arguments to acos and acosl must be in the range -1 to 1, or else acos and acosl return NAN and set the global variable errno to: EDOM Domain error Return Value acos and acosl of an argument between -1 and +1 return a value in the range 0 to pi. Error handling... more | |
Header File math.h Category Math Routines Prototype double asin(double x); long double asinl(long double x); Description Calculates the arc sine. asin of a real argument returns the arc sine of the input value. asinl is the long double version; it takes a long double argument and returns a long double result. Real arguments to asin and asinl must be in the range -1 to 1, or else asin and asinl return NAN and set the global variable errno to EDOM Domain error Return Value asin and asinl of a real argument return a value in the range -pi/2 to pi/2.... more | |
Header File math.h Category Math Routines Prototype double atan(double x); long double atanl(long double x); Description Calculates the arc tangent. atan calculates the arc tangent of the input value. atanl is the long double version; it takes a long double argument and returns a long double result. Return Value atan and atanl of a real argument return a value in the range -pi/2 to pi/2. Error handling for these functions can be modified through the functions _matherr and _matherrl. Example | |
Header File math.h Category Math Routines Prototype double atan2(double y, double x); long double atan2l(long double y, long double x); Description Calculates the arc tangent of y/x. atan2 returns the arc tangent of y/x; it produces correct results even when the resulting angle is near pi/2 or -pi/2 (x near 0). If both x and y are set to 0, the function sets the global variable errno to EDOM, indicating a domain error. atan2l is the long double version; it takes long double arguments and returns a long double result. Return Value atan2 and atan2l return a value in the... more | |
Header File math.h Category Math Routines Prototype double cabs(struct complex z); long double cabsl(struct _complexl z); Description cabs calculates the absolute value of a complex number. cabs is a macro that calculates the absolute value of z, a complex number. z is a structure with type complex; the structure is defined in math.h as struct complex { double x, y; }; where x is the real part, and y is the imaginary part. Calling cabs is equivalent to calling sqrt with the real and imaginary components of z, as shown here: sqrt(z.x * z.x + z.y * z.y) cabsl is... more | |
Header File math.h Category Math Routines Prototype double ceil(double x); long double ceill(long double x); Description Rounds up. ceil finds the smallest integer not less than x. ceill is the long double version; it takes a long double argument and returns a long double result. Return Value These functions return the integer found as a double (ceil) or a long double (ceill). Example | |
Header File math.h Category Math Routines, Inline Routines Prototype double cos(double x); long double cosl(long double x); Description Calculates the cosine of a value. cos computes the cosine of the input value. The angle is specified in radians. cosl is the long double version; it takes a long double argument and returns a long double result. Return Value cos of a real argument returns a value in the range -1 to 1. Error handling for these functions can be modified through _matherr (or _matherrl). Example | |
Header File math.h Category Math Routines Prototype double cosh(double x); long double coshl(long double x); Description Calculates the hyperbolic cosine of a value. cosh computes the hyperbolic cosine: coshl is the long double version; it takes a long double argument and returns a long double result. Return Value cosh returns the hyperbolic cosine of the argument. When the correct value would create an overflow, these functions return the value HUGE_VAL (cosh) or _LHUGE_VAL (coshl) with the appropriate sign, and the global variable errno is set to ERANGE. Error handling for these functions can be modified through the functions _matherr and... more | |
Header File math.h Category Math Routines Prototype double exp(double x); long double expl(long double x); Description Calculates the exponential e to the x. expl is the long double version; it takes a long double argument and returns a long double result. Return Value exp returns e to the x. Sometimes the arguments passed to these functions produce results that overflow or are incalculable. When the correct value overflows, exp returns the value HUGE_VAL and expl returns _LHUGE_VAL. Results of excessively large magnitude cause the global variable errno to be set to | |
Header File math.h Category Math Routines Prototype double fabs(double x); long double fabsl(long double x); Description Returns the absolute value of a floating-point number. fabs calculates the absolute value of x, a double. fabsl is the long double version; it takes a long double argument and returns a long double result. Return Value fabs and fabsl return the absolute value of x. Example | |
Header File math.h Category Math Routines Prototype double floor(double x); long double floorl(long double x); Description Rounds down. floor finds the largest integer not greater than x. floorl is the long double version; it takes a long double argument and returns a long double result. Return Value floor returns the integer found as a double. floorl returns the integer found as a long double. Portability | |
Header File math.h Category Math Routines Prototype double fmod(double x, double y); long double fmodl(long double x, long double y); Description Calculates x modulo y, the remainder of x/y. fmod calculates x modulo y (the remainder f, where x = ay + f for some integer a, and 0 < f < y). fmodl is the long double version; it takes long double arguments and returns a long double result. Return Value fmod and fmodl return the remainder f where x = ay + f (as described above). When y = 0, fmod and fmodl return 0. Example | |
Header File math.h Category Math Routines Prototype double frexp(double x, int *exponent); long double frexpl(long double x, int *exponent); Description Splits a number into mantissa and exponent. frexp calculates the mantissa m (a double greater than or equal to 0.5 and less than 1) and the integer value n such that x (the original double value) equals m * 2n. frexp stores n in the integer that exponent points to. frexpl is the long double version; it takes a long double argument for x and returns a long double result. Return Value frexp and frexpl return the mantissa m. Error... more | |
Header File math.h Category Math Routines Prototype double hypot(double x, double y); long double hypotl(long double x, long double y); Description Calculates hypotenuse of a right triangle. hypot calculates the value z where z2 = x2 + y2 and z >= 0 This is equivalent to the length of the hypotenuse of a right triangle, if the lengths of the two sides are x and y. hypotl is the long double version; it takes long double arguments and returns a long double result. Return Value On success, these functions return z, a double (hypot) or a long double) (hypotl).... more | |
Header File math.h Category Math Routines Prototype double ldexp(double x, int exp); long double ldexpl(long double x, int exp); Description Calculates x * 2^exp. lexpl is the long double version; it takes a long double argument for x and returns a long double result. Return Value On success, ldexp (or ldexpl) returns the value it calculated, x * 2^exp. Error handling for these routines can be modified through the functions _matherr and _matherrl. Example | |
Header File math.h Category Math Routines Prototype ldiv_t ldiv(long int numer, long int denom); Description Divides two longs, returning quotient and remainder. ldiv divides two longs and returns both the quotient and the remainder as an ldiv_t type. numer and denom are the numerator and denominator, respectively. The ldiv_t type is a structure of longs defined in stdlib.h as follows: typedef struct { long int quot; /* quotient */ long int rem; /* remainder */ } ldiv_t; Return Value ldiv returns a structure whose elements are quot (the quotient) and rem (the remainder). Example | |
Header File math.h Category Math Routines Prototype double log(double x); long double logl(long double x); Description Calculates the natural logarithm of x. log calculates the natural logarithm of x. logl is the long double version; it takes a long double argument and returns a long double result. Return Value On success, log and logl return the value calculated, ln(x). errno | |
Header File math.h Category Math Routines Prototype double log10(double x); long double log10l(long double x); Description log10 calculates the base ten logarithm of x. log10l is the long double version; it takes a long double argument and returns a long double result. Return Value On success, log10 (or log10l) returns the calculated value log base ten of x. If the argument x passed to these functions is real and less than 0, the global variable errno is set to | |
Header File math.h Category Math Routines Prototype double modf(double x, double *ipart); long double modfl(long double x, long double *ipart); Description Splits a double or long double into integer and fractional parts. modf breaks the double x into two parts: the integer and the fraction. modf stores the integer in ipart and returns the fraction. modfl is the long double version; it takes long double arguments and returns a long double result. Return Value modf and modfl return the fractional part of x. Example | |
Header File math.h Category Math Routines Prototype double poly(double x, int degree, double coeffs[]); long double polyl(long double x, int degree, long double coeffs[]); Description Generates a polynomial from arguments. poly generates a polynomial in x, of degree degree, with coefficients coeffs[0], coeffs[1], ..., coeffs[degree]. For example, if n = 4, the generated polynomial is: polyl is the long double version; it takes long double arguments and returns a long double result. Return Value poly and polyl return the value of the polynomial as evaluated for the given x. Example | |
Header File math.h Category Math Routines Prototype double pow(double x, double y); long double powl(long double x, long double y); Description Calculates x to the power of y. powl is the long double version; it takes long double arguments and returns a long double result. Return Value On success, pow and powl return the value calculated of x to the power of y. Sometimes the arguments passed to these functions produce results that overflow or are incalculable. When the correct value would overflow, the functions return the value HUGE_VAL (pow) or _LHUGE_VAL (powl). Results of excessively large magnitude can cause... more | |
Header File math.h Category Math Routines Prototype double pow10(int p); long double pow10l(int p); Description Calculates 10 to the power of p. pow10l is the long double version; it takes long double arguments and returns a long double result. Return Value On success, pow10 returns the value calculated, 10 to the power of p and pow10l returns a long double result. The result is actually calculated to long double accuracy. All arguments are valid, although some can cause an underflow or overflow. Example | |
Header File math.h Category Math Routines Prototype double sin(double x); long double sinl(long double x); Description Calculates sine. sin computes the sine of the input value. Angles are specified in radians. sinl is the long double version; it takes a long double argument and returns a long double result. Error handling for these functions can be modified through the functions _matherr and _matherrl. Return Value sin and sinl return the sine of the input value. Example | |
Header File math.h Category Math Routines, Inline Routines Prototype double sinh(double x); long double sinhl(long double x); Description Calculates hyperbolic sine. sinh computes the hyperbolic sine. sinl is the long double version; it takes a long double argument and returns a long double result. Error handling for sinh and sinhl can be modified through the functions _matherr and _matherrl. Return Value sinh and sinhl return the hyperbolic sine of x. When the correct value overflows, these functions return the value HUGE_VAL (sinh) or _LHUGE_VAL (sinhl) of appropriate sign. Also, the global variable errno is set to ERANGE. Example | |
Header File math.h Category Math Routines Prototype double sqrt(double x); long double sqrtl(long double x); Description Calculates the positive square root. sqrt calculates the positive square root of the argument x. sqrtl is the long double version; it takes a long double argument and returns a long double result. Error handling for these functions can be modified through the functions _matherr and _matherrl. Return Value On success, sqrt and sqrtl return the value calculated, the square root of x. If x is real and positive, the result is positive. If x is real and negative, the global variable errno is... more | |
Header File math.h Category Math Routines Prototype double tan(double x); long double tanl(long double x); Description Calculates the tangent. tan calculates the tangent. Angles are specified in radians. tanl is the long double version; it takes a long double argument and returns a long double result. Error handling for these routines can be modified through the functions _matherr and _matherrl.. Return Value tan and tanl return the tangent of x, sin(x)/cos(x). Example | |
Header File math.h Category Math Routines Prototype double tanh(double x); long double tanhl(long double x); Description Calculates the hyperbolic tangent. tanh computes the hyperbolic tangent, sinh(x)/cosh(x). tanhl is the long double version; it takes a long double argument and returns a long double result. Error handling for these functions can be modified through the functions _matherr and _matherrl. Return Value tanh and tanhl return the hyperbolic tangent of x. Example |
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|