The Divide sign is not dividing?
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
No, that's the right answer - you are doing integer division:

399980 / 400000 = 0.99995 AS A FLOAT, but integer divison ALWAYS rounds down so you get 0 * 100 = 0.

The simplest way to solve this is to rearrange your equation:

pawn Код:
vehicleFuel[GetPlayerVehicleID(playerid)] * 100 / 400000
That way you get 39998000 / 400000 = 99.995 as a float, or 99 as an integer.
Thank you very much, it works one hundred percent now. So there is absolutely no way to round up with integers?
Reply


Messages In This Thread
The Divide sign is not dividing? - by Shoulen - 03.04.2013, 12:48
Re: The Divide sign is not dividing? - by Shoulen - 03.04.2013, 12:58
Re: The Divide sign is not dividing? - by Shoulen - 03.04.2013, 13:05

Forum Jump:


Users browsing this thread: 1 Guest(s)