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

18
LINES

< > BotCompany Repo | #1029054 // randomLong

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

Transpiled version (82L) is out of date.

// out of full long range (including negative values)
static long randomLong() {
  ret defaultRandomGenerator().nextLong();
}

static long randomLong(Random random) {
  ret random.nextLong();
}

// returns number between 0 and max-1
static long randomLong(Random random default defaultRandomGenerator(), long max) {
  ret mod(randomLong(random), max);
}

// min <= value < max
static long randomLong(long min, long max) {
  ret min+randomLong(max-min);
}

Author comment

Began life as a copy of #1024425

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1029054
Snippet name: randomLong
Eternal ID of this version: #1029054/6
Text MD5: b2e597b55a7b72ce339e927dffc7549f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-06 21:37:35
Source code size: 471 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 226 / 341
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)