PDA

View Full Version : Calculating defense for uniques?


shyflyrebelguy
04-11-2005, 03:46
I want to figure out the max defense possible on an upped frostburn. I don't know if its 93 or 94. Highest base defense on war gauntlets is 53. So 53*1.2=63.6 At this point I don't know if Im supposed to round up or down to the nearest # before I add the 30 def. Any help?

Orphan
04-11-2005, 04:03
It'd be 93. Although I can't remember if rounding down is used, or whether integer's are just used, I suspect the calculations focus only on integer values.

TheJarulf
04-11-2005, 10:36
It'd be 93. Although I can't remember if rounding down is used, or whether integer's are just used, I suspect the calculations focus only on integer values.


The game uses almost exclusively integer calculations. Interger calculations always truncate the value, so basically you would want to remove the decimals, thus 93 indeed in this case.

Note that truncation is not nessecarilly the same as rounding down,it is so for positive values, but for negatives, it is in fact a rounding up. More correct would be to say that you round towards 0.

Finally notice that for more complex calculations, it might actually be very important to know exactly how the game calculates internally, which is not always the same as the formulas we use. In this example it does not matter, the end result is the same, but in other cases, it might matter. For example, what the game actually do here (since it uses integers, it can't multiply by 1.2) is to take 53 + (53*20)/100 + 30:

53 + (53*20)/100 + 30 = 53 + 1060/100 + 30 = 53 + 10 + 30 = 63 + 30 = 93