-
Sub-task
-
Resolution: Fixed
-
P2
-
None
-
None
1. Let's consider "sumOfSquares += value*value" in code below. I think "value" should be converted to long in order to avoid overflow for big numbers.
class IntSummaryStatistics {
...
@Override
public void accept(int value) {
++count;
sum += value;
sumOfSquares += value*value;
min = Math.min(min, value);
max = Math.max(max, value);
}
...
}
2. Typo: "max = Math.min(max, other.max);", please see code below. The same typo could also be seen in DoblueSummaryStatistics and LongSummaryStatistics.
class IntSummaryStatistics {
...
public void combine(IntSummaryStatistics other) {
count += other.count;
sum += other.sum;
sumOfSquares += other.sumOfSquares;
min = Math.min(min, other.min);
max = Math.min(max, other.max);
}
...
}
class IntSummaryStatistics {
...
@Override
public void accept(int value) {
++count;
sum += value;
sumOfSquares += value*value;
min = Math.min(min, value);
max = Math.max(max, value);
}
...
}
2. Typo: "max = Math.min(max, other.max);", please see code below. The same typo could also be seen in DoblueSummaryStatistics and LongSummaryStatistics.
class IntSummaryStatistics {
...
public void combine(IntSummaryStatistics other) {
count += other.count;
sum += other.sum;
sumOfSquares += other.sumOfSquares;
min = Math.min(min, other.min);
max = Math.min(max, other.max);
}
...
}