Libraryless. Click here for Pure Java version (4614L/26K).
1 | asclass BitOutputStream {
|
2 | abstract void writeBit(bool b); |
3 | |
4 | // little-endian (starts with lowest bit) |
5 | void writeBits(int data, int nBits) {
|
6 | for i to nBits: {
|
7 | writeBit(odd(data)); |
8 | data >>= 1; |
9 | } |
10 | } |
11 | } |
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: | 334 / 464 |
| Referenced in: | [show references] |