Home > Backend Development > PHP Problem > How to remove decimals in php

How to remove decimals in php

coldplay.xixi
Release: 2023-03-06 21:10:01
Original
6885 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template