Then the first value of m is 4. While the second line checks whether 8/3 + 8%3 == 0, which simplifies to 4==0.
I haven’t seen the rest of your code, but this observation might help you.
float type is single-precision floating point and it has significand precision of 24 bits. This means that it cannot accurately represent integers above 2^{24}, which is much lower than the maximum value of k which is 10^9. This introduces an error in your ceil calculation.
An easy way to compute ceil(a / b) for integers a, b without involving floats is (a + b - 1) / b.