static double computeFinalSum(double[] summands){
  double tmp=summands[0] + summands[1];
  double simpleSum=summands[summands.length - 1];
  if (Double.isNaN(tmp) && Double.isInfinite(simpleSum)) {
    return simpleSum;
  }
 else {
    return tmp;
  }
}

static double computeFinalSum ( double [ ] summands ) { double tmp = summands [ 0 ] + summands [ 1 ] ; double simpleSum = summands [ summands . length - 1 ] ; if ( Double . isNaN ( tmp ) && Double . isInfinite ( simpleSum ) ) { return simpleSum ; } else { return tmp ; } }
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 .
