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

11
LINES

< > BotCompany Repo | #1021975 // PosNegScore

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

Libraryless. Click here for Pure Java version (1663L/11K).

srecord PosNegScore(double pos, double neg) implements Comparable<PosNegScore> {
  double diff() { ret pos-neg; }
  
  public int compareTo(PosNegScore s) { ret cmp(diff(), s.diff()); }
  
  toString {
    if (neg == 0) ret pos == 0 ? "0" : "+" + pos;
    if (pos == 0) ret "-" + neg;
    ret "+" + pos + "/-" + neg;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021975
Snippet name: PosNegScore
Eternal ID of this version: #1021975/5
Text MD5: aaf6b05e1b1c944fec4be66545db7a20
Transpilation MD5: 62e36385b532e2523589c68971cd4b2b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-06-25 01:58:34
Source code size: 332 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 274 / 807
Version history: 4 change(s)
Referenced in: [show references]