From: Walter Roberson on
Eshbonzie wrote:

> Is there any way to define the variable size bitwise saving this 14 bits
> for each array cell? or even define the counter as three bytes isntead
> of four and save one byte for each cell?

Sorry, no.

However, if you only need some light operations on the counters (e.g.,
initialize, read current value, increment) then you could define a
simple counter-array class that had the effect you want. The subsref
function for it would take the index given, subtract 1, multiply by 3,
and add the base address of the array to find the starting byte of the
individual counter. Things get messier if you want to start working with
array slices, as you have to decide whether the slice should be
represented as a packed counter-array or as an unpacked uint32 array
From: Walter Roberson on
Eshbonzie wrote:
> Thank you both for your replies, but I still find it so weird that this
> is not an option :S!!
> well...maybe it has to do with the memory allocation and addresses,
> thats why it is not an option.

Note that you cannot do this in C either. C would allow you to construct
a struct that was 3 bytes long, and would allow you to construct arrays
of those structs, but you would not then be able to do arithmetic
directly on those structs.

You might be tempted in C to try to get around that by using arrays of
unions, with one part of the union the struct of 3 bytes and the other
part of the union an unsigned int bitfield of 24 bits, but if you did
that then you encounter the problem that C would consider the bitfield
to be embedded within an "unsigned int" or "unsigned long" (very likely
32 bits) and would thus consider the size of the union to be 32 bits and
_that_ would be the size of each of the array elements, defeating the
packing you were trying to do.

In C++, you would, I think, end up constructing a class for the purpose.