# Mathf.Floor/Editor Common Practices

I’m creating my own level editor and I’m drawing lines to create a grid for a TileMap. I’m having trouble understanding some common practices I’ve seen in comparison to the way I am currently using Mathf.Floor.

`public float height = 32f;`

My code:

``````for (float x = 200; x < 400; x += height)
{
Mathf.Floor(x);
}

//First 3 results:
// 200
// 232
// 264
``````

Other code:

``````for (float x = 200; x < 400; x += height)
{
Mathf.Floor(x/height) * height;
}

//First 3 results:
// 192
// 224
// 256
``````

I’ve noticed that either way in solving this issue, the increment is still going to be 32 units between each result. The resulting grid at the intersects will still produce “perfect” 32x32 squares within the grid. To me, it seems that the resulting values are arbitrary and the only factor necessary to have is the proper increment.

Why is it that dividing and multiplying by height is so common as seen in the second method when using Mathf.Floor?

The second version ensures that the number you come up with is an integer multiple of height; specifically, the integer multiple of height that’s closest to x and less than x.

I’m not convinced that it is all that common to be honest. It would account for a tiny fraction of the many uses I’ve put Floor operations to over the years. But here’s a use case…

Say you have a number of equally spaced horizontal floors, with `dist` being the distance between them.

You could then use `Mathf.Floor( yPos/dist ) * dist` to find the height of the floor that’s below an arbitrary object (the height of the object being `yPos`). The floor, in other words, that the object would hit first it if fell down.