4 ms·
Oh, another useful fact for you - you claimed your routine is good up to $100 billion, that it takes input in pennies, and interest scaled by 1000. Your temp sc
by SideQuark 4y ago
Oh, another useful fact for you - you claimed your routine is good up to $100 billion, that it takes input in pennies, and interest scaled by 1000. Your temp scale factor starts as 10,000, and then is multiplied by 10, so your principal in pennies is scaled by 100,000 before the loop.
The first operation in the loop requires computing P * R. For a rate, say of 8.000%, your rate is 8000, so computing P * R is ($100B * 100) * (100,000) * 8000 = 8 * 10^21, which is a 73 bit number (74 bit for signed).
How exactly do you fit this 74 bit computation in a 64 bit signed int again?
Hopefully this helps you understand your scaled integer solution better.