Skip to content

Instantly share code, notes, and snippets.

@grzhan
Created August 29, 2012 16:47
Show Gist options
  • Save grzhan/3515484 to your computer and use it in GitHub Desktop.
Save grzhan/3515484 to your computer and use it in GitHub Desktop.
Some functions about php float number
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