Is it possible to explain a bit array in C + +? [bitmap] [array in c]

admin / July 31st, 2011/ Posted in Software / No Comments »

Q: I really want to know the easiest way to implement a .


Re:I have a nice binary vector class that I wrote. I could share it if you're interested.
What I use it for is a distributed satellite coverage program I'm working on. I have very large arrays of binary data (whether or not a point on the earth is visible to a particular satellite at a particular time) on different machines in a cluster.
Now, when I send them back over the network, I'm only sending about 1/8th as much data as if I had used a vector of bool or char type. Then I can consolidate the data 32 bits at a time with & and | operators.

Re:I advise anyone against using C++ bit-fields because they can be very inefficient (depending on compiler's implementation). Unless the program saves a significant amount of memory by using bit-fields, I would recommend using bytes instead.

As for re-inventing the wheel, the poster does not seem to have a good grasp on bit-fields, so I think it would be better if he at least tried to do the operations himself before persuing the std library solutions.


Re:Sure, there's a bitset type in the standard library. I'm not a C++ guru so look up the usage for yourself.

guy, why would you reinvent the wheel when the standard library already provides one?


Re:Why do you want to use bit arrays? I would recommend that you use byte arrays and write your own manipulation functions for bits in those arrays.

Related posts


Tags: ,

Leave a Reply

Name required

Mail (will not be published) required

Website