I have a problem doing a division. I have this chunk of code, where this operation must be 40.4239
, but instead i have this result: 0.005595493389623997
I can understand the amount of decimals, I have to solve that with decimalFormat, but I can't understand this result...
contTotal is 288975
in this case, so: (288975/714861)*100 = 40.4239
Any idea...?
int contTotal = 0;
double result = 0;
for(DoubleWritable val : valores) {
contTotal += val.get();
}
result = (contTotal/714861) *100;
Don't know if this helps, but it really looks like you're doing the division twice, since
(40.423/714861)*100
is actually0.005595493389623997
. I would definitely check that.