The difficulty here lies in the precision of floating point numbers. You can: - read each line as INTEGER DOT INTEGER then multiply this by 10, sum everything on a 64bits integers - use long double