Home > Article > Backend Development > How to remove decimals in php
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)].
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!