Definition and usage
The abs () function returns the absolute value of a number.
Syntax
Abs (x)
*/
$ Abs = abs (-3.2); // $ abs = 3.2
$ Abs2 = abs (5); // $ abs2 = 5
$ Abs3 = abs (-5); // $ abs3 = 5
/*
Definition and usage
The ceil () function rounds up to the nearest integer.
Syntax
Ceil (x) parameter description
X is required. A number.
Description
Returns the next integer of no less than x. If x has a decimal part, the return value is one digit. The type returned by ceil () is still float, because the float value range is usually larger than integer.
*/
Echo ceil (5); // 5
Echo "<br> ";
Echo ceil (3.3); // 4
Echo "<br> ";
Echo ceil (6.999); // 7
/*
The floor () function rounds down to the nearest integer.
Syntax
Floor (x) parameter description
X is required. A number.
Description
Returns the next integer not greater than x and rounds the decimal part of x. The return type of floor () is still float, because the float value range is usually larger than that of integer.
*/
Echo floor (4); // 4
Echo "<br> ";
Echo floor (3.3); // 3
Echo "<br> ";
Echo floor (6.999); // 6
/*
Definition and usage
The fmod () function returns the remainder of the floating point number of the division.
Syntax
Fmod (x, y) parameter description
X is required. A number.
Y is required. A number.
Description
Returns the remainder of a floating point number obtained by dividing divide by divisor (y. The remainder (r) is defined as x = I * y + r, where I is an integer. If y is a non-zero value, the symbols of r and x are the same and the number of values is less than y.
*/
$ X = 4.7; // defines the value 1.
$ Y = 1.3; // defines the value 2.
$ R = fmod ($ x, $ y); // perform the remainder operation.
The remainder of echo $ x. "divided by". $ y. "is:". $ r; // output result
/*
The base-10 logarithm of log10.
Syntax
Log10 (x) parameter description
X is required. A number.
Description
Returns the base-10 logarithm of parameter x.
*/
$ Num1 = 100;
$ Num2 = 1000;
$ Num3 = 3;
$ Result1 = log10 ($ num1 );
$ Result2 = log10 ($ num2 );
$ Result3 = log10 ($ num3 );
Echo "$ num1 base-10 logarithm $ result1 ";
Echo "<br> ";
Echo "$ num2 base-10 logarithm $ result2 ";
Echo "<br> ";
Echo "$ num3 base-10 logarithm $ result3 ";
Echo "<br> ";
/*
Log () returns the natural logarithm.
Syntax
Log (x, base) parameter description
X is required. A number.
Base is optional. If this parameter is specified, logbasex is returned.
Description
If the optional parameter base is specified, log () returns logbasex; otherwise, log () returns the natural logarithm of parameter x.
*/
Echo log (2.7183); // returns the natural logarithm of the specified value.
Echo "<br/> ";
Echo log (2); // returns the natural logarithm of the specified value.
Echo "<br/> ";
Echo log (1); // returns the natural logarithm of a specified value.
Echo "<br/> ";
Echo log (0); // returns the natural logarithm of the specified value.
Echo "<br/> ";
Echo log (-1); // returns the natural logarithm of the specified value.
//
Echo sqrt (9); // output 3
Echo "<br> ";
Echo sqrt (10); // 16227766...
//
Var_dump (pow (2, 8); // 256 output
Echo "<br> ";
Echo pow (-1, 20); // output 1
Echo "<br> ";
Echo pow (0, 0); // output 1
Echo "<br> ";
Echo pow (-1, 4.5); // An error is returned.