PHP floor (), round (), Ceil ()

Source: Internet
Author: User

//Down rounding: Gets the nearest integer less than $val
Echo Floor(4.3);//4Echo Floor(9.999);//9Echo Floor(-3.14);//-4Echo Floor(-0.1);//-1//Rounding, second parameter is precision (can be negative)Echo round(0.1);//0Echo round(-3.6);//-4Echo round(-1.95583, 2);//-1.96Echo round(1.95583, 2);//1.96Echo round(1241757,-3);//1242000Rounding up: Gets the most recent integer greater than $valEcho Ceil(-0.1);//0Echo Ceil(0.1);//1Echo Ceil(5.1);//6Echo Ceil(-3.1);//-3


Note: The result values returned by the above three functions are float float type, so be careful with the accuracy problem.

PHP floor (), round (), Ceil ()

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.