A detailed explanation of PHP's numerical functions

Source: Internet
Author: User
This article is mainly to share with you the PHP digital function in detail, mainly and everyone in the form of code to explain, hope to help everyone.

Take the whole

Floor (value) rounding     down Ceil (value)      upward rounding

Power operation

Pow (base, index)

Example

Output 2 of the 3-Time square echo pow (2,3);   8

Square root

sqrt (digital)

Example

The square root of the output 4 echo sqrt (4);  2

Random number

Rand (Start,end)      is slow and Mt_rand (start,end)   recommended, good performance

Digital formatting

Number_format (number (, number of decimal digits))

Only numbers are passed in, and decimals are not preserved, and they are added as separators at the location of thousands , .

Example

Formatted $x = 6789.123;echo Number_format ($x);   6,789echo ' <br/> '; Echo Number_format ($x, 2); 6,789.12echo ' 

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.