Home  >  Article  >  Backend Development  >  How to convert float to int in php

How to convert float to int in php

hzc
hzcOriginal
2020-06-19 16:50:282144browse

How to convert float to int in php

How to convert float to int in php

Use round(x,prec) method

Parameters Description
x Optional. Specifies the number to be rounded.
prec Optional. Specify the number of digits after the decimal point
<?php
echo(round(0.60));
echo(round(0.50));
echo(round(0.49));
echo(round(-4.40));
echo(round(-4.60));
输出:
1
1
0
-4
-5

Recommended tutorial: "php tutorial"

The above is the detailed content of How to convert float to int in php. 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
Previous article:How to use require in PHPNext article:How to use require in PHP