Dive into the details of php's handling of integer functions

  • 2020-06-12 08:45:00
  • OfStack

Ceil: Calculates the minimum integer greater than the specified number.
Floor: Computes the largest integer less than the specified number.
round: 4 rounded to 5.

Choose as needed


<?php
$a=20;
$b = 6;
echo ($a/$b)."<br>"; //out 3.3333333333333
echo ceil($a/$b)."<br>"; //out 4
echo floor($a/$b)."<br>"; //out 3
echo round($a/$b)."<br>"; //out 3
?>


Related articles: