Is there a way for me to get a rounded down number from division math.
I'd like to be able to get a hover position from a division.
example:
Code:hoverx = roundeddownatallcost(mouse_x / TILESIZE;)
Is there a way for me to get a rounded down number from division math.
I'd like to be able to get a hover position from a division.
example:
Code:hoverx = roundeddownatallcost(mouse_x / TILESIZE;)
what are the data types of hoverx,mouse_x and TILESIZE?
I think you want the "floor" function. floor(3) - Linux man page
Example:
Or you can use integer division:Code:double x = 100., y = 3.; double z = floor(x / y);
Note that C rounds the result toward zero, which is different from rounding down only for negative results. If both numbers are always positive then you don't have to worry about this.Code:int x = 100, y = 3; int z = x/y;