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

22
LINES

< > BotCompany Repo | #1023146 // DoomEstimator - guesses when a value will fall below a threshold

JavaX fragment (include)

sclass DoomEstimator {
  long time1, time2;
  double value1, value2;
  double minValue;
  Long doomDate;
  
  *() {}
  *(double *minValue) {}

  // returns true if there is enough info for computing a doom date
  bool consumeValue(double value) {
    time1 = time2;
    value1 = value2;
    time2 = sysNow();
    value2 = value;
    if (time1 == 0) false;
    doomDate = ai_calculateDateOfDoom(time1, value1, time2, value2, minValue);
    true;
  }
  
  bool doomDateReady() { ret time1 != 0; }
}

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: #1023146
Snippet name: DoomEstimator - guesses when a value will fall below a threshold
Eternal ID of this version: #1023146/5
Text MD5: 167c5029188a516da8b8f5432fdde678
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-15 16:07:21
Source code size: 517 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 286 / 697
Version history: 4 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)