Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

14
LINES

< > BotCompany Repo | #1034575 // AverageAndMinMax - collect average, sum, number of values, minimum, maximum

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (13132L/75K).

1  
sclass AverageAndMinMax > Average {
2  
  gettable double min = infinity();
3  
  gettable double max = negativeInfinity();
4  
  
5  
  void add(double d) {
6  
    super.add(d);
7  
    if (d < min) min = d;
8  
    if (d > max) max = d;
9  
  }
10  
  
11  
  toString {
12  
    ret "avg=" + super.toString() + (isEmpty() ? "" : ", min/max=" + min + "/" + max);
13  
  }
14  
}

Author comment

Began life as a copy of #1029191

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034575
Snippet name: AverageAndMinMax - collect average, sum, number of values, minimum, maximum
Eternal ID of this version: #1034575/5
Text MD5: f5cc3807858bb61f058642645f5c7b56
Transpilation MD5: 2e18a81962a7f3e9f9d328bc4f528412
Author: stefan
Category: javax / maths
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-19 05:46:25
Source code size: 337 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 138 / 279
Version history: 4 change(s)
Referenced in: [show references]