I have the following in the program (part of a much larger function, but this is the corresponding bit of testing):
int test = 100 + (100 * (9 / 100)); sprintf (buf, "Test: %d\n\r", test); display_to_pc (buf, player);
This basically amounts to:
x = a + (a * (b / 100))
If a is the given figure, b is the percentage modifier, and x is the result (the original plus the percentage of the original) ... I hope this makes sense.
This gives me:
Test: 100
I thought that the math in my head might be wrong, but I checked several calculators and even an expression evaluator in my IDE, and all of them give me the expected result 109 for the first expression.
Can someone enlighten me about what I do not see here?
Thanks a lot.:)
Level13Cleric
source share