The internal functions of several mathematical computations in PHP learning to organize _php skills

Source: Internet
Author: User
Tags floor function pow rand
Round
Round-rounding floating point numbers. The round function syntax is as follows:

Round (float,precision)
Where the parameter precision represents the number of precision digits to be persisted after the decimal point. If the parameter precision is not written, it is rounded to the integer digit, for example:

Echo round (3.4); 3echo round (3.5); 4echo round (3.6); 4
If precision is 2, it means rounding to 2 digits after the decimal point. Examples are as follows:

Echo Round (1.95583, 2); 1.96
If the parameter precision is a negative number, it is rounded to the decimal point. Like what:

Echo Round (1241757,-3); 1242000
Floor
Floor-the way to the whole. The floor function syntax is as follows:

Floor (value)
The floor function returns the largest integer not greater than value, and the decimal part of value is rounded up. Examples are as follows:

Echo Floor (4); 4
echo floor (4.3); 4echo floor (9.999); 9
Ceil
Ceil-To get the whole in one way. The Ceil function syntax is as follows:

Ceil (value)
The Ceil function returns the smallest integer that is not less than value. Examples are as follows:

Echo Ceil (4); 4
echo ceil (4.3); 5echo ceil (9.999); 10
Pow
Pow-exponentiation. The syntax for the POW function is as follows:

Pow (BASE,EXP)
The POW function returns the power of the base's exp secondary side. The following example represents a 8-time order of 2, and returns a result of 256.

Echo Pow (2, 8); 256
Rand
Rand-produces a random integer. The RAND function syntax is as follows:

Rand (Min,max)
The RAND function returns a random integer between the min min and Max Max (including Min, Max). For example, the following example returns a random integer from 2 to 6.

echo rand (2,6);
Max
Max-Returns the largest value in the parameter.

If the Max function has only one parameter and is an array, MAX returns the largest value in the array.

The Max function example is as follows:

echo Max (1, 3, 5, 6, 7); 7echo Max (Array (2, 4, 5)); 5
Min
Min-Returns the minimum value in the parameter.

If the Min function has only one parameter and is an array, MIN returns the smallest value in the array.

The Min Function example is as follows:

Echo min (1, 3, 5, 6, 7); 1echo min (Array (2, 4, 5)); 2
Decbin
Decbin-Decimal conversion to binary. The Decbin function syntax is as follows:

Decbin (number)
Decbin returns a string that returns the binary representation of the parameter number. Examples are as follows:

Echo Decbin (12);
De>decbin (de>) The result returned is:

1100
Bindec
BINDEC-binary converts to decimal. The BINDEC function syntax is as follows:

Bindec (binary_string)
The BINDEC function converts a binary string binary_string into a decimal integer. Examples are as follows:

echo bindec (' 110011 '); 51
Dechex, Hexdec
Dechex-Decimal conversion to 16.

Hexdec-16 is converted to decimal.

Dechex, the Hexdec function example is as follows:

Echo Dechex (47); 2f
echo hexdec (' 2f '); 47
DECOCT, Octdec
DECOCT-Decimal conversion to octal

Octdec-Eight conversion to decimal

The Decoct,octdec function example is as follows:

Echo decoct (12); 14
Echo Octdec (' 14 '); 12

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.