i know calculating percentages is simple common math we all learned in the 4th grade but im having a problem, porting it to code (man its been over 25yrs)
ok problem 1 is calculating a percentage of numbers less than 100,
this will always be a 1 correct?
INT dmg = 13;
dmg+= (dmg *.05); /* adding the 5% bonus to the damage */
dmg would equal 1 always right? cause that would equal 13.65?
INT dmg = 362;
dmg+= (dmg * .05); /* adding the 5% bonus */
now we get 380.1 so (int)dmg would = 380? and (double)dmg would be 380.1?
the second problem is giving me a bit more trouble, i want to do something similiar to the above problem but pull the percent based off stat value.
im dividing strength by 5 and using that as a percent.
so:
INT strength = 20;
INT bonus = (strength/5);
/* bonus is 5% */
INT dmg = 15;
dmg+=(dmg * .bonus); /* i know this isnt right just to give ya an idea */
how would i add the value bonus as a percent to damage?