What's an efficient way to do exponentials of numbers with decimals, such as when compounding interest rate calculations?
For example: 1.001 ** 69
As of now, I naively implement it like this:
uint mantissa = 1e3; uint rate = 1; uint periods = 69; uint out = mantissa; for(uint i=0; i < periods; i++){ out = out * (mantissa + rate); out = out / mantissa; } My worry is if the number of periods get big then I'm running a pretty inefficient loop. Anyone have any better ideas? Are there any libraries that do this implementation for me? Thanks!