fixed precision loss in average computation, close #2016