What is the most efficient way in Java to pack bits into byte[] and read it back?
I currently use these two functions to pack and read bits in a byte array. Wondering if anybody has any better ideas or faster ways to do it? Edited the program with a few more optimization and tabled a few calculations. Currently 100mil Put and Get takes about 12 secs instead of 16 secs now. If anybody is using the current code make sure the value passed in to Put is a positive number as it's expecting unsigned numbers coming down. If there is interest I can put up signed and unsigned versions. class BitData { static void Put(byte Data[], final int BitOffset, int NumBits, final int Value) {