Home  >  Article  >  Backend Development  >  PHP floating point number rounding rounding

PHP floating point number rounding rounding

WBOY
WBOYOriginal
2016-07-28 08:27:521502browse
<?php
 $a = 1.1;
 $b = 3.9;

 //取整数部分
 echo floor($a);	// 1
 echo floor($b);	// 3

 // 进一取整
 echo ceil($a);		// 2
 echo ceil($b);		// 4

 // 四舍五入
 echo round($a);	// 1
 echo round($b);	// 4
?>

The above has introduced PHP floating point number rounding, rounding, and rounding, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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