我正在使用JavaScript记录事件发生之间的时间。

因此,我将间隔设置为10


gameTimer = setInterval(incTime,10);


最后,例如,如果我得到99,如何将其转换为float变量(0.099)?

最佳答案

最后,例如,如果我得到99,如何将其转换为浮点数
  变量(0.099)?


您可以将其除以1000。如下所示:-

var a = 99;
var b = 99/1000.0;
var result = b.toFixed(3); //Use this if you want to restrict the number after the decimal. Like 0.099

关于javascript - 将间隔数转换为float变量,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19346612/

10-10 00:42
查看更多