Summing doubles can cause a loss of precision.Summing integers, however, doesn't. (Assuming no overflow.)Here's a high precision sum function I wrote:#include <iostream>#include <vector>#include <cmath>#define BASE 10bool is_int(double n) {  double intpart;  return std::modf(n, &intpart) == 0.0;}double sum(std::vector<double> nums) {  int n = nums.size();  int maxepower = 1;  for (int i = 0; i < n; ++i) {    while(!is_int(nums[i] * pow(BASE, maxepower))) { maxepower++; }  }  int pieces[n];  for (int i = 0; i < n; ++i) {    pieces[i] = nums[i] * pow(BASE, maxepower);  }  int sum = 0;  for (int i = 0; i < n; ++i) {    sum += pieces[i];  }  return sum / pow(BASE, maxepower);}I'm new to C++ so extra feedback on idioms would be helpful.EDIT:Example:int main() {  std::cout << 0.1 + 0.2 - 0.3 << std::endl;  std::cout << sum({0.1, 0.2, -0.3}) << std::endl;}gives5.55112e-170
Precision sum of doubles
c++;beginner