As long as your grid is regular, just find a transformation from integers to this grid. So let’s say your grid is
0.2 0.4 0.6 ...
Then you round by
float round(float f)
{
return floor(f * 5 + 0.5) / 5;
// return std::round(f * 5) / 5; // C++11
}