Chris G
Chris G

Reputation: 57

C# uint64 -- Store data?

Is there a better way to store numerical data in an uint64 other than using x digits for one piece, y digits for other stuff? (20 digits total to work with)

I am trying to store information about an object without having the overhead of making a struct or class. I need to get/set as fast as possible with minimal overhead.

Upvotes: 0

Views: 219

Answers (2)

Sebastian 506563
Sebastian 506563

Reputation: 7228

So, as far as I know voxels coding. If you want to store "blocks" data that is defined one by one then you can use interval tree , where the key of each node is the start of a run and the value is the coordinate of the run. Implemntation example.

Also, you NEVER store single block as class but SET of blocks for example block 3x3 can be done as:

enter image description here

as you see I just coded data position of 9 blocks in two bits This is simplified method for which data size is not the problem but fast implementation of iteration that needs form you some algorithm.

Before you even start play with Voxels read these

Let's Make a Voxel Engine

Damn, Voxel Data is BIG

Voxel engines are everywhere…

Voxel Engine – Data Storage

Internet is full of answeres, but these will give your information that you need. Also keyword that I think you were mising is VOXEL

Upvotes: 3

ashes999
ashes999

Reputation: 10163

If using uint64 or ulong is not a fixed requirement, I suggest you use the BigInteger class. It was designed to efficiently store arbitrarily-large numbers.

Is it efficient? If you decompile the code, you'll see that they store an array of bits internally to manage the number. That is, with N bits, it stores a number up to 2^N - 1.

Upvotes: 1

Related Questions