Home  >  Article  >  Web Front-end  >  js decimal rounding function_basic knowledge

js decimal rounding function_basic knowledge

WBOY
WBOYOriginal
2016-05-16 18:27:391174browse

1. Discard the decimal part and keep the integer part

js:parseInt(7/2)

2. Round up, if there is a decimal, add 1 to the integer part

js: Math.ceil(7/2)

3, round down.
js: Math.round(7/2)

4, round down

js : Math.floor(7/2)

Statement:
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