I'm building a calculator web app as a learning exercise, and when I got to the percent function I noticed something strange.
While entering this input on an iPhone calculator - I didn't have a handheld calculator available to verify this - I got this output.
4, *, %, -> (0.04), = (0.16)
but
4, +, %, -> (0.16), = (4.16)
What is confusing here is that the first operation seems to be applying the percent function to the number (4) resulting in the intermediate value of $(0.04)$ and then multiplying that by the number (4) and resulting in $(0.16)$ $4 * (0.04) = 0.16$
However, the addition does not seem to be doing the same number of operations. It seems to be taking the percent of the number (0.04) and be multiplying it by the number (4) and then adding the number (4) and resulting in $(4.16)$ $4 + 4 * 0.04 = 4.16$
Can some one explain this?
Is this correct?
What math rule is this following?
Or have I perhaps stumbled upon a bug?
Also if this is not the correct forum for this question please let me know which is the correct forum.