Home > Web Front-end > JS Tutorial > body text

Keep to one decimal place without rounding

巴扎黑
Release: 2016-12-10 09:09:52
Original
1847 people have browsed it

Retain one significant figure without rounding;

For example: 199.999

is processed as follows

var str = parseFloat(199.999).toFixed(10);//Write 10 here to ensure that several decimal places are retained, after it The little one’s number is 0 without rounding, so the result is what you want

var num = str.substring(0,str.lastIndexOf('.')+2) +"万";

After the following processing, num becomes 199.9


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!