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

11
LINES

< > BotCompany Repo | #1006949 // tossCoin

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

Libraryless. Click here for Pure Java version (4674L/26K).

static bool tossCoin() {
  ret oneIn(2);
}

static bool tossCoin(Random random) {
  ret oneIn(2, random);
}

sbool tossCoin(double probability) {
  ret randomZeroToOneExclusive() < probability;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1006949
Snippet name: tossCoin
Eternal ID of this version: #1006949/3
Text MD5: d2daeccb5f5f4a7b3726cc0c37873a31
Transpilation MD5: 04f63f3d4368619baa0780df8aeee34e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-12-26 16:39:19
Source code size: 205 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 510 / 644
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1006950 - tossACoin - synonym of tossCoin
#1009148 - oneInTwoChance - synonym of tossCoin
#1036331 - securelyTossCoin