Options to store a smaller byte?

I have long multidimensional arrays that contain values ​​that range from 0 to 16.

They are currently stored as:

byte[][,] example = new byte[1024][16,16]; 

This is about 300 KB.

Is there a more efficient way to store this data? Since the byte can be 0 - 255, this is ideal for a single line of 16 values ​​with a range of 0-15.

+4
source share
1 answer

BitVector32 allows you to pack 8 4-bit values ​​into a 32-bit integer. Since you essentially have 64-bit in each dimension of your array (16 lines of 16 4-bit values, if I understand correctly), you might be interested in this class .

+4
source

Source: https://habr.com/ru/post/1446811/


All Articles