-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,889
  • 2
  • 18
  • 36
rmaik
  • 1,076
  • 3
  • 15
  • 48

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
  • 387,369
  • 54
  • 702
  • 768