2

我听说现代系统中的位移操作实际上比乘法和除法要慢,因为它们必须传递更多参数。真的吗?

4

1 回答 1

0

No, it isn't. A C compiler will choose the fastest operations for your processor, regardless of how you specify them.

A poster child of strength reduction is replacing x / 2 with x >> 1 in source code. In 1985, that was a good thing to do; nowadays, you're just making your compiler yawn. https://www.facebook.com/notes/facebook-engineering/three-optimization-tips-for-c/10151361643253920

于 2013-04-27T21:52:20.043 回答