code: static double computeFinalSum(double[] summands) {
          // Better error bounds to add both terms as the final sum
          double tmp = summands[0] + summands[1];
          double simpleSum = summands[summands.length - 1];
          if (Double.isNaN(tmp) && Double.isInfinite(simpleSum))
              return simpleSum;
          else
              return tmp;
      }
docs: If the compensated sum is spuriously NaN from accumulating one
  or more same-signed infinite values, return the
  correctly-signed infinity stored in the simple sum.