How can I calculate an equation with decimal point exponents on a primitive calculator?

39 Views Asked by At

By primitive calculator, I really mean a type of scripting that can only calculated by adding, subtracting, multiplying, and dividing numbers that can be either negative or positive but not a decimal.

With the script, I can't just input an equation. I will have to write out each step manually. Thankfully it shouldn't too hard (planning to do exponents by making it multiply itself recursively).

As an example equation, I have $1-(1-0.50)^{1.5\cdot1.5\cdot1.3}$

(For context, it's the equation Pokemon Go uses to calculate whether a pokemon will be caught or not- modified a bit so that it fits what I am trying to do. Contains Base Capture Rate and Throw, Ball, and Berry modifiers. https://bulbapedia.bulbagarden.net/wiki/Catch_rate_(GO))

At first, I thought I could just multiply everything by 100 to make them all whole and then divide it by 100 after but the issue that I found was that it does not work well with exponents.

With experimenting, I found that something like $100-\frac{(100-50)^\frac{(15*15*13)}{1000}}{10000}$ works, but sometimes it gives me numbers way over 100 when the goal of the equation is to get a number between 1 and 100.

The way the script works is each line can compare two values, the second(source) affecting the first(target) depending on which operation you specify.

List of operations:
"+=" Addition: Add source's score to that of target
"-=" Subtraction: Subtract source's score from that of target
"*=" Multiplication: Set target's score to the product of target's and source's scores
"/=" (Integer) Division: Divide target's score by source's score, and use the result (rounded down) to set the target score.
"%=" Modulus: Divide target's score by source's score, and use the remainder to set the target score
"=" Assign: Set target's score to that of source
"<" Min: Set target's score to source's score only if source has the lesser score.
">" Max: Set target's score to source's score only if source has the greater score.
"><" Swaps target's and source's scores

Essentially I have been sticking to multiplying the exponent's values together and then I will recursively multiply the value that has the exponent by itself however many times the exponent is. But how can I do this while retaining the original equation's goal? Am I doing this all wrong and thinking too much when there's an easier way to do the same thing?