What is a good solution for calculating an average where the sum of all values exceeds a double’s limits?
You can calculate the mean iteratively. This algorithm is simple, fast, you have to process each value just once, and the variables never get larger than the largest value in the set, so you won’t get an overflow. double mean(double[] ary) { double avg = 0; int t = 1; for (double x : ary) … Read more