I have a Array that stores my map data and my Tiles are 64X64. Sometimes I need to convert from pixels to units of tiles. So I was doing:
int x
int y
public void myFunction()
{
getTile((int) Math.floor(x / TILE_SIZE), (int) Math.floor(y / TILE_SIZE)).doOperation();
}
But I discovered by using (I'm using java BTW) System.out.println((int) (1 / 1.5))
that converting to an int automatically rounds down. This means that I can replace the (int) Math.floor with just x / 64.
But if I run this on a different OS do you think it might give a different result? I'm just afraid there might be some case where this would round up and not down. Should I keep doing it the way I was and maybe make a function like convert(int i) to make it easier? Or is it OK to just do x / 64?