Do math functions of constant expressions get pre-calculated at compile time?

后端 未结 6 1106
感动是毒
感动是毒 2020-12-06 17:10

I tend to use math functions of constant expressions for convinience and coherence (i.e log(x)/log(2) instead of log(x)/0.3...). Since these functi

6条回答
  •  时光取名叫无心
    2020-12-06 17:51

    It depends. If the compiler can do the math exactly as it would be done at runtime, and if link time optimizations are performed, and if the library is kept in some sort of intermediate form, then yes it could be done.

    Most compilers don't do all of that.

提交回复
热议问题