The asin() function returns the arc sine ofarg, which will be in the range [-pi/2, +pi/2].argshould be between -1 and 1. Ifargis outside this range, asin() returns NAN and raises a floating-point exception.
The abs() function returns the absolute value ofnum. For example:
This section will cover the Math elements of the C Standard Library.
For example, the following code displays the quotient and remainder of x/y:
The function cosh() returns the hyperbolic cosine ofarg.
The pow() function returnsbaseraised to theexpth power. Theres a domain error if base is zero andexpis less than or equal to zero. Theres also a domain error if base is negative andexpis not an integer. Theres a range error if an overflow occurs.
The atan2() function computes the arc tangent of y/x, using the signs of the arguments to compute the quadrant of the return value.
Pages with syntax highlighting errors
The function frexp() is used to decomposenuminto two parts: a mantissa between 0.5 and 1 (returned by the function) and an exponent returned asexp. Scientific notation works like this:
If you dont want cmath you can write sin function it is;
. There aretemplate/file changesawaiting review.
The acos() function returns the arc cosine ofarg, which will be in the range [0, pi].argshould be between -1 and 1. Ifargis outside this range, acos() returns NAN and raises a floating-point exception.
The exp() function returns e (2.7182818) raised to theargth power.
acos-asin-atan-atan2-cos-cosh-sin-sinh-tan
The function sinh() returns the hyperbolic sine ofarg.
The function labs() returns the absolute value ofnum.
The ceil() function returns the smallest integer no less than num. For example:
The function log() returns the natural (base e) logarithm ofnum. Theres a domain error ifnumis negative, a range error ifnumis zero.
double sin(double x) //sin function return x-((x*x*x)/6.)+((x*x*x*x*x)/120.)
From Wikibooks, open books for an open world
C++ Programming/Code/Standard C Library/Math
The ldiv() function returns the quotient and remainder of the operationnumerator/denominator. Theldiv_tstructure is defined in cstdlib and has at least:
The function atan() returns the arc tangent ofarg, which will be in the range [-pi/2, +pi/2].
The function floor() returns the largest integer value not greater than arg.
The sqrt() function returns the square root ofnum. Ifnumis negative, a domain error occurs.
The ldexp() function returnsnum* (2 ^exp). And get this: if an overflow occurs,HUGE_VALis returned.
C++ ProgrammingCode/Standard C Library
The fmod() function returns the remainder of x/y.
The function sin() returns the sine ofarg, whereargis given in radians. The return value of sin() will be in the range [-1,1]. If arg is infinite, sin() will return NAN and raise a floating-point exception.
The function tanh() returns the hyperbolic tangent ofarg.
The cos() function returns the cosine ofarg, whereargis expressed in radians. The return value of cos() is in the range [-1,1]. Ifargis infinite, cos() will return NAN and raise a floating-point exception.
The function modf() splitsnuminto its integer and fraction parts. It returns the fractional part and loads the integer part intoi.
The function fabs() returns the absolute value ofarg.
would result in x being set to 6 (double 6.0).
The function div() returns the quotient and remainder of the operationnumerator/denominator. Thediv_tstructure is defined in cstdlib, and has at least:
In order to calculate the logarithm of x to an arbitrary base b, you can use:
The tan() function returns the tangent ofarg, whereargis given in radians. Ifargis infinite, tan() will return NAN and raise a floating-point exception.
Thelatest reviewed versionwascheckedon
Text is available under theCreative Commons Attribution-ShareAlike License.; additional terms may apply. By using this site, you agree to theTerms of UseandPrivacy Policy.
Thelog10()function returns the base 10 (or common) logarithm fornum. There will be a domain error ifnumis negative and a range error ifnumis zero.
would result in x being set to -7 (double -7.0).
This page was last edited on 1 January 2014, at 16:14.