Problem adding double

  • Thread starter Thread starter laninialarva
  • Start date Start date
L

laninialarva

Guest
I need to do average of 3 scores:

double aux1=8.9,aux2=9.0,aux3=9.4;
double sum = double(aux1+aux2+aux3);
double average= sum/double(3);

sum must be 27.3 and average must be 9.1

but sum= 27.299999 and average is 9.09999


I can not round, I must trucate the average.

What can I do to avoid this problem? Thanks

Continue reading...
 
Back
Top