Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javascript 转换 #38

Open
hsipeng opened this issue Mar 16, 2018 · 0 comments
Open

javascript 转换 #38

hsipeng opened this issue Mar 16, 2018 · 0 comments

Comments

@hsipeng
Copy link
Owner

hsipeng commented Mar 16, 2018

一、取整
1,直接取整(丢弃小数部分)

var num = parseInt(5/3);  // 1

2,四舍五入取整

var num = Math.round(5/3);  // 2

3,向上取整

var num = Math.ceil(5/3);  // 2

4,向下取整

var num = Math.floor(5/3);  // 1

参考连接

保留小数点后N位

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant