You can simplify Knolan's formula, and cut out the need for finding floor(), by using the float value of n instead. In the above example where you have 5 cells x and 2 cells y, you would come out with:
n = (5/2) = 2.5
so that for every time your x movement is >= 2.5 you move 1 y and store the remainder (.5) in your counter variable. I would write this up like:
5/2 = 2.5 only if you are using float, it is 2 if you are using integers.
I would tell you to avoid using floats in this case (grids), they are slower and your algorithm will be doing a lot of conversions.
Also, floats don't add any advantage to the algorithm... if neeeded, use the mod operation (x%y) to find the integer remaining value of a division.