-2

i do not know why i am getting the average = 0. the code below shows how i calculate it, and the image posted below shows what i am getting as output

Code

    float avg = (goodMatchesList.size()/rawMatchesListSorted.size()) * 100;
    Log.D(TAG, "descMatcher", "avg: " + avg);
    Log.D(TAG, "descMatcher", "min: " + minDist);
    Log.D(TAG, "descMatcher", "max: " + maxDist);
    Log.D(TAG, "descMatcher", "objComputedDescExt.rows: " + matFactory.getComputedDescExtMatAt(0).rows());
    Log.D(TAG, "descMatcher", "rawMatchesListSorted.size: " + rawMatchesListSorted.size());
    Log.D(TAG, "descMatcher", "goodMatchesList.size: " + goodMatchesList.size());

enter image description here

Calum
  • 1,809
  • 2
  • 19
  • 35
rmaik
  • 1,552
  • 3
  • 14
  • 44

1 Answers1

5

You are dividing two integers - (goodMatchesList.size()/rawMatchesListSorted.size()), so if the result is smaller than 1, it becomes 0.

For floating point division, use casting :

((float)goodMatchesList.size()/rawMatchesListSorted.size())*100

or multiple by 100 before dividing if you don't care about fractions:

100*goodMatchesList.size()/rawMatchesListSorted.size()
Eran
  • 374,785
  • 51
  • 663
  • 734