Field for sequence of bits

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to save 192 bit-values in 12 integers. How do I save this information
in a field in a table?

Can I save it in a text field – and how do I the extract the data in the
right format?

I will later use the bit in a bit operation using the AND operator on
another similar structure. Maybe I have to do this one integer at a time – so
perhaps the solution is to have 12 integer fields in my table. But I would
prefer to have one field and then map the content into a structure with 12
integers (using lset).
 
Dear Diane,

In .Mdb files, boolean values are treated differently to most other data
types. If you have a series of boolean values, they are stored in a bitmask
within the file structure - therefore your 192 bit values if stored as 192
boolean fields would only take up 24 bytes per record in your mdb file.

Therefore I see no advantage to trying to store these fields yourself in 12
seperate integer fields (12 x 2bytes = 24 bytes) unless you are trying to
query multiple bit values at a time by using the AND operator. Or perhaps
by having 192 fields poses a problem due to the 256 limit?... Perhaps you
could explain why you want to do this...

Anyway, to answer your question, you could map the 192 bit values into a
string, but working with strings (manipulation/extraction etc) would make
this much much harder (and far slower) to query or change the data.
Therefore 12 integer fields would be more appropriate.

However, I've just thought of another problem that you might incurr.
Integer values in Access and VBA are 16 bit signed values - this will likely
screw up any AND operator (or indeed any other bitwise operator) you try to
use if the 16th bit has been set (in LSB-MSB terms) since the 16th bit is
used to determine sign. So you would probably have to convert each
Signed-Integer into a Long (on demand) to preserve the 16th bit.
Alternatively, you might want to consider only using 15 bits per integer to
work around the problem.

I would still suggest thinking again about this because VBA & Access were
never designed to use bitwise operators (in fact I don't think Access has a
bitwise AND function/operator.... you'll probably have to use VBA functions
to query/update the values... good luck if you choose this route).

Regards,

Wayne Phillips
http://www.everythingaccess.com
 
Back
Top