简体   繁体   中英

Javascript remove numbers after the dot

Lets say i have this number: 1.5676556 But i want it to show only 1 (without rounding, lets say i have 0.6, if i use math.round, it will round it to 1)

tnx in advanced.

使用Math.floor(0.6) ,或者如果你真的想使用字符串操作, String(0.6).split('.')[0]

尝试这个:

0.12345678.toFixed(2) // "0.12"

如果数字大于0,您正在寻找Math.floor

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