C + + Nineth lesson Standard C Math function

Source: Internet
Author: User
Tags acos asin cos natural logarithm pow sin square root

ABS ()

Seek absolute value

ACOs ()

Seeking the inverse cosine

ASIN ()

Ask for the inverse of the string

Atan ()

Ask for anyway cut

ATAN2 ()

To find the tangent, to determine the quadrant by symbol

Ceil ()

Minimum integer (for upper bound) not less than a value

cos ()

Find cosine

Cosh ()

Find hyperbolic cosine

Div ()

Seeking quotient and remainder

EXP ()

Ask for the power of E

Fabs ()

Find the absolute value of a floating-point number

Floor ()

The largest integer that is not greater than a value (for the lower bound)

Fmod ()

Calculate modulus

Frexp ()

The scientific representation form of the seeking number

Labs ()

To find the absolute value of a long integer number

Ldexp ()

Calculate with scientific counting method

Ldiv ()

Return quotient and remainder with long integer type

Log ()

Natural logarithm

LOG10 ()

Natural logarithm at base of 10

MODF ()

Break a number into integers and fractional parts

POW ()

exponentiation

Sin ()

Seeking sine

Sinh ()

Finding hyperbolic sine

sqrt ()

Find square root

Tan ()

Seeking Tangent

Tanh ()

To find hyperbolic tangent

Abs

Grammar:

#include <stdlib.h>
int, ABS (int num);

Function: The function returns the absolute value of the parameter num. For example:

int magic_number = 10;
cout << "Enter a guess:";
CIN >> X;
cout << "Your guess was" << abs (magic_number-x) << "away from the magic number." << Endl;

Related Topics:
Labs ().

ACOs

Syntax:

#include <math.h>
Double ACOs (double arg);

Function: The function returns the inverse cosine value of the parameter arg . The parameter arg should be between 1 and 1.

Related Topics:
ASIN (), Atan (), atan2 (), sin (), cos (), tan (), Sinh (), cosh (), and Tanh ().

Asin

Syntax:

#include <math.h>
Double asin (double arg);

Function: The function returns the inverse chord value of the parameter arg . The parameter arg should be between 1 and 1.

Related Topics:
ACOs (), Atan (), atan2 (), sin (), cos (), tan (), Sinh (), cosh (), and Tanh ().

Atan

Syntax:

#include <math.h>
Double Atan (double arg);

Function: The function returns the inverse tangent value of the parameter arg .

Related Topics:
ASIN (), ACOs (), atan2 (), sin (), cos (), tan (), Sinh (), cosh (), and Tanh ().

Atan2

Syntax:

#include <math.h>
Double atan2 (double y, double x);

Function: The function calculates the inverse tangent value of the y/x, and calculates the quadrant according to the symbol of the parameter.

Related Topics:
ASIN (), ACOs (), Atan (), sin (), cos (), tan (), Sinh (), cosh (), and Tanh ().

Ceil

Syntax:

#include <math.h>
Double ceil (double num);

Function: function returns the smallest integer with a parameter that is not less than num . For example

y = 6.04;
x = Ceil (y);

X is 7.0.

Related Topics:
Floor () and Fmod ().

Cos

Syntax:

#include <math.h>
Double cos (double arg);

Function: The function returns the cosine of the parameter arg , withArg given in radians.

Related Topics:
ASIN (), ACOs (), Atan (), sin (), atan2 (), tan (), Sinh (), cosh (), and Tanh ().

Cosh

Syntax:

#include <math.h>
Double cosh (double arg);

Function: function returns the hyperbolic cosine of the parameter arg .

Related Topics:
ASIN (), ACOs (), Atan (), sin (), atan2 (), tan (), sinh (), cos (), and Tanh ().

Div

Syntax:

#include <stdlib.h>
div_t Div (int numerator, int denominator);

Function: function returns the quotient and remainder of the parameter numerator / denominator . The structure type div_t is defined in Stdlib.h:

int quot; Quotient
int rem; Remainder

example, the following code shows the quotient and remainder of X/y:

div_t temp;
temp = div (x, y);
printf ("%d divided by%d yields%d with a remainder of%d\n", X, Y, Temp.quot, Temp.rem);

Related Topics:
Ldiv ().

Exp

Syntax:

#include <math.h>
Double exp (double arg);

Function: function returns the arg power of the parameter returns E (2.7182818).

Related Topics:
Log ().

Fabs

Syntax:

#include <math.h>
Double fabs (double arg);

Function: The function returns the absolute value of the parameter arg .

Related Topics:
ABS ().

Floor

Syntax:

#include <math.h>
Double floor (double arg);

Function: The function returns the largest integer with a parameter that is not greater than arg . For example

y = 6.04;
x = Floor (y);

The value of X is 6.0.

Related Topics:
Ceil ().

Fmod

Syntax:

#include <math.h>
Double Fmod (double x, double y);

Function: The function returns the remainder of the parameter x/y .

Related Topics:
Ceil (), floor (), and Fabs ().

Frexp

Syntax:

#include <math.h>
Double frexp (double num, int *exp);

Function: The function divides the parameter num into two parts: the mantissa between 0.5 and 1 (returned by the function) and returns the exponent exp. Converted to the following scientific notation form:

num = Mantissa * (2 ^ exp)

Related Topics:
Ldexp ().

Labs

Syntax:

#include <stdlib.h>
Long Labs (long num);

Function: The function returns the absolute value of the parameter num .

Related Topics:
ABS ().

Ldexp

Syntax:

#include <math.h>
Double ldexp (double num, int exp);

Function: function returns the parameter num * (2 ^ exp). Returns Huge_val if an overflow occurs .

Related Topics:
Frexp () and MODF ().

Ldiv

Syntax:

#include <stdlib.h>
ldiv_t Ldiv (long numerator, long denominator);

Function: function returns the quotient and remainder of the parameter numerator / denominator . The structure type ldiv_t is defined in Stdlib.h:

Long REM; Remainder

Related Topics:
Div ().

Log

Syntax:

#include <math.h>
Double log (double num);

Function: The function returns the natural logarithm of the parameter num . If num is negative, a domain error occurs and a range error occurs if num is zero.

Related Topics:
LOG10 ().

Log10

Syntax:

#include <math.h>
Double log10 (double num);

Function: The function returns the logarithm of the parameter num at base 10. If num is negative, a domain error occurs and a range error occurs if num is zero.

Related Topics:
Log ().

Modf

Syntax:

#include <math.h>
Double modf (double num, double *i);

Function: The function divides the parameter num into integers and decimals, returns the fractional part and assigns the integer part to i.

Related Topics:
Frexp () and Ldexp ().

Pow

Syntax:

#include <math.h>
Double pow (double base, double exp);

Function: The function returns the exp Power at the base of the parameter base . If base is zero or negative and exp is less than or equal to zero or non-integer, a domain error is generated. If overflow, the range error is generated.

Related Topics:
exp (), log (), and sqrt ().

Sin

Syntax:

#include <math.h>
Double sin (double arg);

Function: The function returns the sine of the parameter arg , andArg is given in radians.

Related Topics:
ASIN (), ACOs (), Atan (), cosh (), atan2 (), tan (), sinh (), cos (), and Tanh ().

Sinh

Syntax:

#include <math.h>
Double Sinh (double arg);

Function: The function returns the hyperbolic sine value of the parameter arg .

Related Topics:
ASIN (), ACOs (), Atan (), cosh (), atan2 (), tan (), sin (), cos (), and Tanh ().

sqrt

Syntax:

#include <math.h>
Double sqrt (double num);

Function: The function returns the square root of the parameter num . If num is negative, a domain error is generated.

Related Topics:
exp (), log (), and POW ().

Tan

Syntax:

#include <math.h>
Double tan (double arg);

Function: The function returns the tangent of the parameter arg ,Arg given in radians.

Related Topics:
ASIN (), ACOs (), Atan (), cosh (), atan2 (), Sinh (), sin (), cos (), and Tanh ().

Tanh

Syntax:

#include <math.h>
Double Tanh (double arg);

Function: function returns the hyperbolic tangent of the parameter arg .

Related Topics:
ASIN (), ACOs (), Atan (), cosh (), atan2 (), tan (), sin (), cos (), and Sinh ().

C + + Nineth lesson Standard C Math function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.