30.12.2012, 01:08
Another important thing if you do maths with integer, always use the division as last!
Lets check out this example, normally you would think it works like that
158 / 4 * 3 = 39.5 * 3 = 118.5
158 * 3 / 4 = 474 / 4 = 118.5
But the truth is that the fractional part is cut off each time resulting in
158 / 4 * 3 = 39.5 * 3 => 39 * 3 = 117
158 * 3 / 4 = 474 / 4 = 118.5 => 118
Lets check out this example, normally you would think it works like that
158 / 4 * 3 = 39.5 * 3 = 118.5
158 * 3 / 4 = 474 / 4 = 118.5
But the truth is that the fractional part is cut off each time resulting in
158 / 4 * 3 = 39.5 * 3 => 39 * 3 = 117
158 * 3 / 4 = 474 / 4 = 118.5 => 118
pawn Код:
new robmoney = (((400 - rob[id]) * 3) / 4);