If you are using a grid like system and you want to know the current grid id of your entity, something as follows works quite nicely:
id_x = floor(my.x/10);
id_y = floor(my.y/10);
You can shift the position naturally if the ids don't match your system (i.e. an entity receives the next higher id too early when moving in one direction):
id_x = floor((my.x-5)/10);
id_y = ...