For more accuracy, consider Kahan Summation...

"In particular, simply summing n numbers in sequence has a worst-case error that grows proportional to n, and a root mean square error that grows as √n for random inputs. With compensated summation, the worst-case error bound is effectively independent of n, so a large number of values can be summed with an error that only depends on the floating-point precision."

https://en.wikipedia.org/wiki/Kahan_summation_algorithm

#computerscience
#compsci
#WilliamKahan

@sohkamyung

Kahan summation algorithm - Wikipedia