Home > Backend Development > PHP Tutorial > Several ways of rounding in php_PHP tutorial

Several ways of rounding in php_PHP tutorial

WBOY
Release: 2016-07-13 17:44:44
Original
864 people have browsed it

floor is rounded by rounding. Grammar format: float floor (float value)

Returns the next integer not greater than value, rounding off the decimal part of value. The type returned by floor() is still float, because the range of float values ​​is usually larger than that of integer.

echo floor(4.3); // 4

echo floor(9.999); // 9

ceil rounding method syntax format: float ceil (float value)

Returns the next integer that is not less than value. If value has a decimal part, it is rounded up by one digit. The type returned by ceil() is still float, because the range of float values ​​is usually larger than that of integer

echo ceil(4.3); // 5

echo ceil(9.999); // 10

round Rounds floating point numbers

Syntax: float round ( float val [, int precision] )

echo round(3.4);              // 3

echo round(3.5);              // 4

echo round(3.6);              // 4

echo round(3.6, 0); // 4

echo round(1.95583, 2); // 1.96

echo round(1241757, -3); // 1242000

echo round(5.045, 2); // 5.05

echo round(5.055, 2); // 5.06

This article is from the “Technology Makes Dreams” blog

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478725.htmlTechArticlefloor rounding syntax format: float floor (float value) returns the next integer not greater than value, Round off the decimal part of value. The type returned by floor() is still float...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template