I want to round a float number to a given precision, for example :
0.051 i want to convert it to
0.1
0.049 i want to convert it to
0.0
0.56 i want to convert it to
0.6
0.54 i want to convert it to
0.5
I cant explain it better, but the reason for this is to translate a point location (like 0.131f, 0.432f) to the location of tile in a grid (like 0.1f, 0.4f).
As long as your grid is regular, just find a transformation from integers to this grid. So let’s say your grid is
Then you round by