Home >Backend Development >PHP Problem >Which PHP function rounds up?

Which PHP function rounds up?

(*-*)浩
(*-*)浩Original
2019-09-21 14:22:433649browse

PHP ceil() function

Which PHP function rounds up?

Definition and usage

ceil() function round up Enter to the nearest integer.

Grammar (Recommended learning: PHP programming from entry to proficiency)

ceil(x)

Instructions

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

Example

In this example, we will apply the ceil() function to different values:

<?php
echo(ceil(0.60);
echo(ceil(0.40);
echo(ceil(5);
echo(ceil(5.1);
echo(ceil(-5.1);
echo(ceil(-5.9));
?>

Output:

1
1
5
6
-5
-5

The above is the detailed content of Which PHP function rounds up?. For more information, please follow other related articles on the PHP Chinese website!

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