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

6
LINES

< > BotCompany Repo | #1033665 // arrayOfRandomBitsAsInts

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

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

1  
static int[] arrayOfRandomBitsAsInts(int n, double probability) {
2  
  int[] data = new[n];
3  
  int nBits = n*4;
4  
  for i to nBits: if (tossCoin(probability)) setBitInIntArray_littleEndian(data, i);
5  
  ret data;
6  
}

Author comment

Began life as a copy of #1033662

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033665
Snippet name: arrayOfRandomBitsAsInts
Eternal ID of this version: #1033665/1
Text MD5: 9c795247647713c5ac7b4229b9fc6686
Transpilation MD5: 8f2643f05854053916442fc386d2dede
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:40:56
Source code size: 211 bytes / 6 lines
Pitched / IR pitched: No / No
Views / Downloads: 171 / 222
Referenced in: [show references]