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 functions aren’t actually a part of the language itself, neither are they defined in math.h (only declared), will the constant ones get precalculated at compile time, or will they be wastefully calculated at runtime?
I tend to use math functions of constant expressions for convinience and coherence (i.e
Share
Some compilers will evaluate them at compile time, but this behavior is not guaranteed (and doing so may also cause problems). You’ll need to check your compiler and see what it does.
Note that on many systems,
log(2)is available from the macroM_LN2in<math.h>.