Skip to main content

15.4.13 Math command

15.4.13.1 Sin

Explanation

sin() is used to calculate the sine of parameter x and return the result.

Definition

double sin(double x)

x in radians;

Return value: Return the calculated result between -1 and 1.

15.4.13.2 Cos

Explanation

cos() is used to calculate the cosine of parameter x and return the result.

Definition

double cos(double x)

x in radians;

Return value: Return the calculated result between -1 and 1.

15.4.13.3 Tan

Explanation

tan() is used to calculate the tangent of parameter x and return the result.

Definition

double tan(double x)

x in radians;

Return value: Return the tangent of parameter x.

15.4.13.4 Cot

Explanation

cot() is used to calculate the cotangent of parameter x and return the result.

Definition

double cot(double x)

x in radians;

Return value: Return the cotangent of the parameter x.

15.4.13.5 Asin

Explanation

asin() is used to calculate the arcsine of parameter x and return the result.

Definition

double asin(double x)

Parameter x ranges from -1 to 1, beyond which error will be reported.

Return value: Return the calculated result between -PI/2 and PI/2, in radians.

15.4.13.6 Acos

Explanation

acos() is used to calculate the arccosine of parameter x and return the result.

Definition

double acos(double x)

Parameter x ranges from -1 to 1, beyond which error will be reported;

Return value: Return the calculated result between 0 and PI, in radians.

15.4.13.7 Atan

Explanation

atan() is used to calculate the arctangent value of parameter x and return the result.

Definition

double atan(double x)

Return value: Return the calculated result between -PI/2 and PI/2.

15.4.13.8 Sinh

Explanation

tanh() is used to calculate the hyperbolic tangent of parameter x and return the result.

Definition

double sinh(double x)

The mathematical definition is: (exp(x) - exp(-x))/2;

Return value: Return the hyperbolic sine of parameter x.

15.4.13.9 Cosh

Explanation

cosh() is used to calculate the hyperbolic cosine of parameter x and return the result.

Definition

double cosh(double x)

The mathematical definition is: (exp(x)+exp(x))/2;

Return value: Return the hyperbolic cosine of the parameter x.

15.4.13.10 Tanh

Explanation

tanh() is used to calculate the hyperbolic tangent of parameter x and return the result.

Definition

double tanh(double x)

The mathematical definition is: sinh(x)/cosh(x);

Return value: Return the hyperbolic tangent of parameter x.

15.4.13.11 Exp

Explanation

exp() is used to calculate e to the x power, which is the e^x value, and return the result;

Definition

double exp(double x)

Return value: Return the result of e to the x power.

15.4.13.12 Ln

Explanation

ln() is used to calculate the logarithm value of x at the base of e and return the result.

Definition

double ln(double x)

Function description: Find the natural logarithm of x, ln(x), x > 0;

Return value: Return the natural logarithm value of parameter x.

15.4.13.13 log10

Explanation

log10() is used to calculate the logarithm value of x at the base of 10, and return the result.

Definition

double log10(double x)

Where x>0;

Return value: Return the natural logarithm value of parameter x at the base of 10.

15.4.13.14 pow

Explanation

pow() is used to calculate x to the y power, which is the xy value, and return the result;

Definition

double pow(double x, double y)

Return value: Return the result of x to the y power.

15.4.13.15 sqrt

Explanation

sqrt() is used to calculate the square root of parameter x and return the result.

Definition

double sqrt(double x)

The parameter x must be positive;

Return value: Return the square root of parameter x.

15.4.13.16 ceil

Explanation

ceil() will return the minimum integer value no less than parameter x, and the result will be returned in the double type.

Definition

double ceil(double x)

Return value: Return a minimum integer value not less than the parameter x.

15.4.13.17 floor

Explanation

floor() will return the maximum integer value not greater than the parameter x, and the result will be returned in the double type.

Definition

double floor(double x)

Return value: Return the maximum integer value not greater than the parameter x.

15.4.13.18 abs

Explanation

Find the absolute value of x, |x|;

Definition

int abs(int x)/double abs(double x)

Return value: When the input parameter is of int type, the output is also of int type. When the input parameter is of double type, the output is also.

15.4.13.19 rand

Explanation

To generate an integer random number;

Definition

rand()

Return value: An integer random number, ranging from 0 to 2147483647.