Is Multiplying the Inverse Better or Worse?

前端 未结 11 1203
忘了有多久
忘了有多久 2020-12-20 13:52

When dealing with double data types is multiplying by the inverse better or worse?

Which way is faster? Which way uses

11条回答
  •  半阙折子戏
    2020-12-20 14:34

    The answer will depend on the architecture of the executing environment. In general, divisions are usually slightly more costly than multiplication on most processors.

    So unless this is actually a performance concern, I probably wouldn't worry about it. Pick the conversion factor that's more understandable.

提交回复
热议问题