gpt4 book ai didi

actionscript-3 - 在 AS3 中,当值大于最大 int 时,getTimer() 将返回什么

转载 作者:行者123 更新时间:2023-12-01 05:27:00 26 4
gpt4 key购买 nike

Adobe getTimer() 是:

Used to compute relative time. For a Flash runtime processing ActionScript 3.0, this method returns the number of milliseconds that have elapsed since the Flash runtime virtual machine for ActionScript 3.0 (AVM2) started.



由于 getTimer 返回一个 int ,其中:

The int class lets you work with the data type representing a 32-bit signed integer. The range of values represented by the int class is -2,147,483,648 (-2^31) to 2,147,483,647 (2^31-1)



getTimer() 在 2,147,483,647 毫秒后返回什么?我认为这大约是连续运行 24.85 天。这不是通常的情况,但对于数字标牌和自助服务终端而言,这是完全可行的。

在这些情况下应该避免 getTimer() 吗? Date.UTC() 对象是否会更安全,因为它返回一个 Number 类型?

最佳答案

我的猜测是它会自己循环,就像 int 一样。

var nt:int = int.MAX_VALUE + 10; //outputs -2147483639
var nt2:int = int.MIN_VALUE + 9; //outputs -2147483639

如您所见, MAX + 10MIN + 9 相同(显然,必须考虑最小值本身)。因此,当您达到 24 天标记时,它可能看起来像 -24 天并开始回升。

函数本身也有可能不返回实际时间,而是返回以下内容:
return timer % int.MAX_VALUE;

这将使用简单的模数将每次达到 MAX_VALUE 时的时间重置为 0。老实说,如果这是他们所做的,我不会感到惊讶(因为显然您不想要负面的运行时间)

关于actionscript-3 - 在 AS3 中,当值大于最大 int 时,getTimer() 将返回什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13404573/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com