求负数最快的方法
这条线有没有最快的方法?
ballAngelRadianVector = -ballAngelRadianVector;
还有这个:
ballDegree = fee - ballDegree ;
Is there any Fastest way for this line?
ballAngelRadianVector = -ballAngelRadianVector;
and also this:
ballDegree = fee - ballDegree ;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不认为你能比这更快..请参阅我所做的快速检查:
I don't think you can get faster than that.. See this quick check I did:
我实际上出于好奇而想知道类似的东西(我知道这不是我的应用程序的瓶颈)。我的问题是,将 var 设置为自身的负数或将其乘以 -1 是否更容易。我想知道这是否因CPU、操作系统等而异,但我运行了以下测试:
产生了输出:
所以看起来乘以-1始终更快(可以忽略不计)
i was actually wondering something similar strictly from curiosity (i know this is not the bottleneck of my application). my question is, is it easier to set a var to a negative of itself, or to multiply it by -1. i am wondering if this varies from CPU, OS, etc, but i ran the following test:
which produced the output:
so it looks like multiplying by -1 is consistently faster (by a negligible amount)