Rounding to nearest 100

前端 未结 7 819

First number needs to be rounded to nearest second number. There are many ways of doing this, but whats the best and shortest algorithm? Anyone up for a challenge :-)

7条回答
  •  感动是毒
    2020-12-15 05:02

    As per Pawan Pillai's comment above, rounding to nearest 100th in Javascript:
    100 * Math.floor((foo + 50) / 100);

提交回复
热议问题