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

11
LINES

< > BotCompany Repo | #1033627 // BitOutputStream

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

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

asclass BitOutputStream {
  abstract void writeBit(bool b);
  
  // little-endian (starts with lowest bit)
  void writeBits(int data, int nBits) {
    for i to nBits: {
      writeBit(odd(data));
      data >>= 1;
    }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033627
Snippet name: BitOutputStream
Eternal ID of this version: #1033627/1
Text MD5: 56e578fb2ba3fa8b276400c06c0ed1a9
Transpilation MD5: a5927c0715956e1f057e59d49b8e043b
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-12-22 14:23:21
Source code size: 235 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 134 / 218
Referenced in: #1033629 - PrintingBitOutputStream
#1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)