Hello, I am working on a project in which I have multiple 16x128x16 chunks of data(basically just a 3d array). I need to save the chunks so that they can be easily and quickly rebuilt later. The problem is that each element in the chunk is a short, so each chunk uses a lot of space. Would there be some algorithm that I could use to add all the values in the chunk together, then generate a key to rebuild the chunk based on the values added to it? If not, what is some other efficient approach that I could take?

Recommended Answers

All 3 Replies

It takes 8 bits to store a short, no matter how you decide to store it. So unless you have some way to compress the data you aren't going to be saving any space.

Does the data have large groupings of the same value?

What is the maximum value you are putting into these shorts? Are they signed? If you are not filling the shorts right up, and they aren't signed, then maybe you can get away with packing them all into maybe 12 bits rather than 16 (a short is 2 bytes (16 bits not 8 bits as said above)).

You are correct, comes from dealing with multiple programming languages where everyone has their own definition of 'short' :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.