How can I round down a number in Javascript?

前端 未结 11 1378
感动是毒
感动是毒 2020-11-29 23:27

How can I round down a number in JavaScript?

math.round() doesn\'t work because it rounds it to the nearest decimal.

I\'m not sure if there is

11条回答
  •  庸人自扰
    2020-11-29 23:54

    You need to put -1 to round half down and after that multiply by -1 like the example down bellow.

    
    
    

    Round number 1.25 down:

    Round number 1.25 up:

提交回复
热议问题