Floor(x) means the greatest integer less than or equal to x.
Would this formula work, or are you looking for something simpler? Because this is all I could come up with.
You can see how I got this if you look at how many squares you intersect when you go to the left 1 unit. If we let X equal the slope, then is the number of squares intersected across the first column. The same basic rule would apply for subsequent columns, but you must subtract the amount intersected in the previous columns.