How can I use round()
to round a number to the superior number as soon as there is a decimal?
For example:
1.00001 = 2
1.1 = 2
1.4785834975 = 2
1.00 = 1
1.99 = 2
3.01 = 4
How can I use round()
to round a number to the superior number as soon as there is a decimal?
For example:
1.00001 = 2
1.1 = 2
1.4785834975 = 2
1.00 = 1
1.99 = 2
3.01 = 4
Yes, what you are looking for is called ceil
<?php
echo ceil(4.3); // 5
echo ceil(9.999); // 10
echo ceil(-3.14); // -3
?>
This might be helpful for you:
floor()
will go down.
ceil()
will go up.
round()
will go to nearest by default.
<?php
echo ceil(3.4); // 4
echo ceil(8.89); // 9
?>