Why doesn't a compiler optimize floating-point *2 into an exponent increment?

前端 未结 9 1604
悲&欢浪女
悲&欢浪女 2021-02-06 20:45

I\'ve often noticed gcc converting multiplications into shifts in the executable. Something similar might happen when multiplying an int and a float. F

9条回答
  •  野性不改
    2021-02-06 21:45

    A previous Stackoverflow question about multiplication by powers of 2. The consensus, and the actual implementations, proved that unfortunately, there is no current way to be more efficient than standard multiplication.

提交回复
热议问题