• Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Icon: P2 P2
    • None
    • None
    • core-libs

      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);
              }
          ...
          }

            mduigou Mike Duigou
            grakov Georgiy Rakov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: