Integer (integer type)
Integer is an integral type. In a 32-bit operating system, its valid range is 2,147,483,648 to +2,147,483,647 (2^31+ sign bit). To use a 16-digit integer, you can add 0x to the polygon. Integer values can be specified in decimal, hexadecimal, or octal notation, preceded by an optional symbol (-or +).
Decimal: If you see 15 o'clock, it means (1*10+5) or 1510
Contains (0 ... 9) 10 digits
Octal: If you see 15 o'clock, it means (1*8+5) or 158 or 1310
Contains (0 ... 7) Eight digits
Hex: If you see 15 o'clock, it means (1*16+5) or 1516 or 2110
Contains (0 ... 9,A,B,C,D,E,F) 16 digits
If the octal notation is used, the number must be preceded by 0 (0) and the hexadecimal symbol must be preceded by a 0x.
$a = 1234; Decimal number
$a =-123; A negative number
$a = 0123; Octal number (equal to 83 in decimal)
$a = 0x1A; Hexadecimal number (equals 26 in decimal)
?>
Float (also called floating-point number, double-precision, or real)
Floating-point numbers are floating-point numbers. In a 32-bit operating system, its valid range is 1.7E-308 to 1.7E+308. (Natural base e=2.71828183)
$a = 1.234;
$a = 1.2e3;
$a = 7E-10;
?>
$foo = 10; $foo is an integer $bar = (bool) $foo; $bar is a Boolean ?> |
The allowable casts are:
(int)-Convert to Integer no rounding (bool)-Convert to Boolean not 0 positive or negative is true (float), (double), (real)-Convert to floating point (string)-Convert to String
Library of mathematical operations functions
Abs
Get the absolute value.
Syntax: Mixed ABS (mixed number);
Return value: Mixed type data
Types of functions: mathematical operations
Returns the absolute value of the parameter number. If number is a multiple-precision floating-point, the return value is also a double-floating point, and the other type is an integer.
Acos
Gets the inverse cosine value.
Syntax: float acos (float arg);
return value: Floating-point number
Types of functions: mathematical operations
Returns the inverse cosine value of the parameter arg (ARC cosine).
Asin
Get the inverse sine value.
Syntax: Float ASIN (float arg);
return value: Floating-point number
Types of functions: mathematical operations
Returns the inverse chord value of the parameter arg (arc sine).
Atan
Gets the inverse tangent value.
Syntax: float atan (float arg);
return value: Floating-point number
Types of functions: mathematical operations
Returns the inverse tangent value of the parameter arg (arc tangent).
Atan2
Calculates the inverse tangent of two numbers. Syntax: float atan2 (float y, float x); Return value: Type of floating-point function: mathematical operation
This function is used to calculate the inverse tangent of two number y, X, and the computed result is similar to Atan () calculation y/x, but this function will affect the result by the sign of X, Y. And the return value of this function must fall between positive and negative pi (-pi <= (value) ≶= pi)
Bindec
Binary turns into 10.
Syntax: int bindec (string binary_string);
return value: Integer
Types of functions: mathematical operations
This function converts a binary numeric string into an integer that is 10. Since PHP uses a 32-bit signed integer, the maximum number of decimal digits that can be processed is 2147483647, which is 1111111111111111111111111111111 (31 1) of the binary number.
Ceil
Calculates the smallest integer greater than the specified number.
Syntax: int ceil (float number);
return value: Integer
Types of functions: mathematical operations
This function is used to calculate the smallest integer larger than the floating-point parameter number.
This example returns a value of 4.
$nextint =ceil (3.14);
Echo $nextint;
?>
Cos
Cosine calculation.
Syntax: float cos (float arg);
return value: Floating-point number
Types of functions: mathematical operations
This function calculates the cosine value of the parameter arg (cosine).
Decbin
Decimal round binary.
Syntax: string decbin (int number);
return value: String
Types of functions: mathematical operations
This function turns the decimal number into a binary string. Since PHP uses a 32-bit signed integer, the maximum number of decimal digits that can be processed is 2147483647, which is 1111111111111111111111111111111 (31 1) of the binary number.
Exp
The secondary value of the natural logarithm E.
Syntax: float exp (float arg);
return value: Floating-point number
Types of functions: mathematical operations
This function calculates the arg value of the natural logarithm (natural logarithm).
Floor
Calculates the largest integer less than the specified number.
Syntax: int floor (float number);
return value: Integer
Types of functions: mathematical operations
This function is used to calculate the largest integer smaller than the floating-point parameter number.
This example returns a value of 3.
$lastint =floor (3.14);
Echo $lastint;
?>
Max
Gets the maximum value.
Syntax: Mixed max (mixed arg1, mixed arg2 .... mixed argn);
Return value: Mixed type data
Types of functions: mathematical operations
This function calculates the maximum value between parameters. If the first argument is a numeric array, the maximum number of the array is found. If the first parameter is not an array, then more than two parameters are required. These numbers can be integers, multiples of exact numbers, or types of numeric strings. The number of parameters is not limited, depending on the needs of users. In the calculation, as long as one parameter is the exact number of times, this function will turn all the parameters into multiples of the exact number and return the exact number of times. If the argument has only integers and numeric strings, all arguments are converted to integers and integers are returned.
Min
Gets the minimum value.
Syntax: mixed min (mixed arg1, mixed arg2 .... mixed argn);
Return value: Mixed type data
Types of functions: mathematical operations
This function calculates the minimum value between the parameters. If the first argument is a numeric array, the smallest number of the array is found. If the first parameter is not an array, then more than two parameters are required. These numbers can be integers, multiples of exact numbers, or types of numeric strings. The number of parameters is not limited, depending on the needs of users. In the calculation, as long as one parameter is the exact number of times, this function will turn all the parameters into multiples of the exact number and return the exact number of times. If the argument has only integers and numeric strings, all arguments are converted to integers and integers are returned.
Number_format
Formats a numeric string.
Syntax: string Number_format (float number, int [decimals], string [Dec_point], string [thousands_sep]);
return value: String
Types of functions: mathematical operations
This function is used to format the floating-point parameter number. If the parameter is not decimals the returned string is returned as long as the integer part is added to the number of decimal places specified by the parameter. The parameter dec_point represents the method of how the decimal point is represented, and the default value is ".", which can be broken in this parameter if it needs to be converted to another decimal point. The parameter thousands_sep is a three-bit separator for integral parts, and the default value is ",". The most special place of this function is the number of parameters, at least one, that is, to format the string, you can have two or four parameters, but not three parameters. To administer a raise? Note that the number of digits after the specified decimal point is discarded directly, without rounding the case.
$short _pi = "3.14159";
$my _pi = Number_format ($short _pi, 2);
echo $my _pi. " \ n "; 3.14
$foo = 850017.9021;
$new _foo = Number_format ($foo, 3, ".", "");
echo $new _foo. " \ n "; 850 017.902
?>
Pi
Pi.
Syntax: Double pi (void);
Return value: The exact number of times
Types of functions: mathematical operations
This function returns the PI. No input parameters are required.
Pow
The second party.
Syntax: Float POW (float base, float exp);
return value: Floating-point number
Types of functions: mathematical operations
This function calculates the sub-square value. The parameter base is the base and exp is the power number.
Print (POW (2,3)); 8
Print (POW (5,4)); 625
?>
Rand
Obtain a random value.
Syntax: int rand ([int min], [int Max]);
return value: Integer
Types of functions: mathematical operations
This function is used to obtain a random value. Without specifying the maximum and minimum range of random numbers, this function automatically takes a random number from 0 to Rand_max. If a parameter of min and Max is specified, a number is taken from the specified parameter. For example, Rand (38, 49) takes a random value from 38 to 49, and the UNIX system contains 49, and the WIN32 system does not contain a zkimmel@earthlink.net 10-may-1999. It is important to note that in order to make the random number the most chaotic, it is best to use Srand () to configure a new random number seed each time before taking the random number.
Round
Rounded.
Syntax: Double round (double val);
Return value: The exact number of times
Types of functions: mathematical operations
This function is used to round a digit after a decimal point.
$foo 1 = round (3.4);
$foo 2 = round (3.5);
$foo 3 = round (3.6);
echo "Round (3.4):". $foo 1. "
\ n ";
echo "Round (3.5):". $foo 2. "
\ n ";
echo "Round (3.6):". $foo 3;
?>
Sin
Sine calculation.
Syntax: float sin (float arg);
return value: Floating-point number
Types of functions: mathematical operations
This function calculates the sine value of the parameter arg (sine).
Sqrt
Open square root.
Syntax: float sqrt (float arg);
return value: Floating-point number
Types of functions: mathematical operations
This function opens the square root of the argument Arg.