简体   繁体   English

将带十进制的毫秒转换为毫秒

[英]convert millisecond with decimal into millisecond

In Midi timing, I have calculated to convert MIDI time to millisecond but contains decimal numbers (eg 2000.5454545454).在 Midi 计时中,我计算将 MIDI 时间转换为毫秒,但包含十进制数字(例如 2000.5454545454)。 To reduce the loss of precision, what is the best solution to convert into millisecond without the decimal so that the Actionscript can time accurately?为了减少精度损失,什么是不带小数的毫秒转换的最佳解决方案,以便 Actionscript 可以准确计时? Math.Round?数学圆?

Math.Round is a fine option. Math.Round 是一个不错的选择。 If this is a running total and you want to avoid cumulative errors you should keep the running total un-rounded and just pass the rounded value to whatever you're doing in Actionscript.如果这是一个运行总计,并且您想避免累积错误,您应该保持运行总计未舍入,并将舍入值传递给您在 Actionscript 中所做的任何事情。 That way you'll never be more than a millisecond off.这样你就不会超过一毫秒。

Try尝试

trace(Math.Round(2000.54545454));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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