Created
August 29, 2012 16:47
-
-
Save grzhan/3515484 to your computer and use it in GitHub Desktop.
Some functions about php float number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php 小数整理,向上取整,向下去整,四舍五入,丢弃小数部分,保留整数部分(转) | |
1.丢弃小数部分,保留整数部分 | |
php: intval(7/2) | |
js:parseInt(7/2) | |
2.向上取整,有小数就整数部分加1 | |
php: ceil(7/2) | |
js: Math.ceil(7/2) | |
3,四舍五入. | |
php: round(7/2) | |
js: Math.round(7/2) | |
4,向下取整 | |
php: floor(7/2) | |
js: Math.floor(7/2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment