简体   繁体   中英

Cutting excessive trails off a float

I am getting numbers back from postgre db in float format and when trying to print them in my html page they took too much space. How do I cut the excessive precision number using a quick JS function? ie:

98.7776 --> 98.7
var num = 98.7776;
var result = num.toFixed(1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM