In a loop I am adding 0.10 till I reach the desired #, and getting the index. This is my code :
private static int getIndexOfUnits(float units) { int
You shouldn't use float's for this kind of thing (indexing / iterating).
Try calculating I every time:
I = 1.0f + (i*addup);
And you'll not accumulate floating-point errors.