13 lines
453 B
Plaintext
13 lines
453 B
Plaintext
// stream of bytes to numBits sized ints, 1<numBits<32
|
|
fcn fromBytes(n,[(numBits,acc,bitsSoFar,buf)]state){
|
|
acc=acc.shiftLeft(8) + n; bitsSoFar+=8;
|
|
buf.clear();
|
|
while(bitsSoFar>=numBits){
|
|
bitsSoFar-=numBits;
|
|
buf.append(acc.shiftRight(bitsSoFar));
|
|
acc=acc.bitAnd((-1).shiftLeft(bitsSoFar).bitNot());
|
|
}
|
|
state.clear(numBits,acc,bitsSoFar,buf);
|
|
return(Void.Write,Void.Write,buf); // append contents of buf to result
|
|
}
|