Home  >  Article  >  Backend Development  >  How to remove decimals in php

How to remove decimals in php

coldplay.xixi
coldplay.xixiOriginal
2020-10-30 15:42:186561browse

php method to remove decimals: 1. Discard the decimal part and keep the integer part [intval(7/2)]; 2. Round up, if there is a decimal, add 1 to the integer part [ceil(7/2)] ]; 3. Rounding [round(7/2)]; 4. Rounding down [floor(7/2)].

How to remove decimals in php

php method to remove decimals:

1. Discard the decimal part and keep the integer part

php: intval(7/2)

js:parseInt(7/2)

2. Round up, if there are decimals, add the integer part 1

php: ceil(7/2)

js: Math.ceil(7/2)

3. Rounding.

php: round(7/2)

js: Math.round(7/2)

4. Round down

php: floor(7/2)

js: Math.floor(7/2)

If you want to learn more about programming, please stay tuned php training column!

The above is the detailed content of How to remove decimals 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