Search code examples
c#.netperformancemath

Why isn't there Math.Pow that takes an int as the exponent?


I read that the Math.Pow implementation is pretty complicated to be able to handle fractional powers. Why isn't there a version that takes an int for the exponent to make a faster version when you don't need fractional powers?


Solution

  • Because you'd just need to convert it back into a float to multiply it against the logarithm of the base.

    nm = em × ln n