Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这个算法集(在我的脑海中),它需要我在一个循环中多次将 float 转换为 int (每 16 毫秒大约 300 次)。我的问题是这样的:
在 java/android 中从 float 转换为 int 的过程有多昂贵,它会导致游戏变慢吗?
我的游戏可以实现它是否足够便宜?如果没有,将十进制转换为整数的其他选项是什么?
编辑:问题解决了!
从 float 到 int 的转换不会比任何其他赋值语句花费更多。它由硬件处理。分配(取决于架构)通常花费一个周期或一次通过管道(非常非常快)。我不会担心这种转换对您的表现的影响。