Calculationg the percentage.
I am trying to calculate a percentage.
Code :
double percentage = (numberMatchedEntries / numberEntriesFile1) * 100;
numberMatchedEntries = 20
numberEntriesFile1 = 52
So the output would be about: 38.1%
But from this code:
(numberMatchedEntries / numberEntriesFile1)
I only get 0 back, and not 0,381
I tried using a float too, but it still keeps 0.
And I realy don't know why?
Re: Calculationg the percentage.
What data types are used in the formula? With integer arithmetic: 6/10= 0
using doubles: 6.0/10 = 0.6
Re: Calculationg the percentage.
That would be it.
Those two are int's.
I will change that.
Thanks.