I have the following C# code:
int cellHeight = (int)Math.Floor((ClientSize.Height - controlsSpacing) / 25f);
int yStart = MarginSize + controlsSpacing;
for (int i = 0; i < 25; i++)
{
g.DrawRectangle(Pens.Black, 0 + MarginSize, yStart, ClientSize.Width - MarginSize - 1,
cellHeight);
yStart += cellHeight;
}
What I am trying to do is draw 25 lines that extend from the top to the bottom and are equally spaced out to fit into the ClientSize area. The problem I have is that the last line drawn always seems to be smaller or larger then the rest of them. My math must be failing somewhere. Any help would be appreciated.
Here is a screen shot:

The problem is
The fraction that you remove by using
Math.Flooris missing in each iteration and accumulates to the gap you see.Calculate
yStartin each iteration: