Minecraft mob spawning distance?

In minecraft you have to be 24 blocks i think away from mobs so they will spawn I built a mob spawn farm 21 blocks above me, so how far away do i need to be on ground level? How do i work it out?

Added (1). In other words, how do i tell how many blocks away i'm from something if it's above me?

Between 16 and 24 blocks is the best distance for mobs to spawn. To find out how far away you could pillar up or build a staircase and count how blocks up you go, or you can get the coordinates of your Y axis either by pressing F3 or by using a map (for consoles) and simply doing a little bit of maths to find out the distance from ground level to the floor of your spawn room.