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.

1  
// out of full long range (including negative values)
2  
static long randomLong() {
3  
  ret defaultRandomGenerator().nextLong();
4  
}
5  
6  
static long randomLong(Random random) {
7  
  ret random.nextLong();
8  
}
9  
10  
// returns number between 0 and max-1
11  
static long randomLong(Random random default defaultRandomGenerator(), long max) {
12  
  ret mod(randomLong(random), max);
13  
}
14  
15  
// min <= value < max
16  
static long randomLong(long min, long max) {
17  
  ret min+randomLong(max-min);
18  
}

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: 225 / 340
Version history: 5 change(s)
Referenced in: [show references]