In my game, there is a point where a multiplier of 1.5 is applied to a variable. I want a way to simply either round it up or down, either one is fine.
I've tried looking at past forum posts for an answer, but I don't understand any of the ones I could find.
There are four functions to round a number:
floor - rounds downceiling - rounds upround - rounds to the closest whole numbertruncate - discards the part after the decimalBut it might be quicker and easier to stick with integer arithmetic. If a sum includes no decimals, the answer won't either.
a = b * 1.5 gives a decimal because there's a decimal "1.5"a = b * 3 / 2.0 gives the same answera = b * 3 / 2 gives the same number rounded off (if b is an int), because / only returns the integer part if its arguments are integers.So if you want your answer to be a whole number, it's easier to work with fractions :)