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

8
LINES

< > BotCompany Repo | #1035197 // reverseBits - reverses all bits in int (or only n lowest bits)

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

Libraryless. Click here for Pure Java version (37L/1K).

static int reverseBits(int i, int bits default 32) {
  int j = 0;
  repeat bits {
    j = (j << 1) | (i & 1);
    i >>>= 1;
  }
  ret j;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1035197
Snippet name: reverseBits - reverses all bits in int (or only n lowest bits)
Eternal ID of this version: #1035197/5
Text MD5: 7d21027b4ee92c2edcee04908f6f2e4b
Transpilation MD5: 2d45059d5e4f79f7eafa9beaf951a5ff
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-04-15 01:06:44
Source code size: 145 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 147 / 217
Version history: 4 change(s)
Referenced in: [show references]