D
Danny Anderson
Hola!
I have an array of shorts that represents a stream of data. This data is
packed in tight, so certain elements may actually contain data for more
than one variable.
I am to decipher this stream. The first variable packed into this array
happens to be a short, meaning I get away with a simple assignment:
myFirstVariable=myArray[0];
My problem is that mySecondVariable is a char. What that means is that
the char I need is making up 50% of myArray[1].
How can I get those 8 bits, and only those 8 bits? This is a pretty big
sticking point, because it follows naturally that myThirdVariable starts
in the second half of myArray[1]. In attempting to come up with the right
answer from this datastream, I have tried all kinds of crazy,
groping-in-the-dark kinds of casts, etc., obviously without any luck.
My new tact is going to be trying division, or, along the same vein,
bitwise operations on myArray[1] in an attempt to get my 8 bits. Am I
heading down the right path? If not, would some kind soul steer me
towards the light?
Any help or suggestions much appreciated!
Danny
I have an array of shorts that represents a stream of data. This data is
packed in tight, so certain elements may actually contain data for more
than one variable.
I am to decipher this stream. The first variable packed into this array
happens to be a short, meaning I get away with a simple assignment:
myFirstVariable=myArray[0];
My problem is that mySecondVariable is a char. What that means is that
the char I need is making up 50% of myArray[1].
How can I get those 8 bits, and only those 8 bits? This is a pretty big
sticking point, because it follows naturally that myThirdVariable starts
in the second half of myArray[1]. In attempting to come up with the right
answer from this datastream, I have tried all kinds of crazy,
groping-in-the-dark kinds of casts, etc., obviously without any luck.
My new tact is going to be trying division, or, along the same vein,
bitwise operations on myArray[1] in an attempt to get my 8 bits. Am I
heading down the right path? If not, would some kind soul steer me
towards the light?
Any help or suggestions much appreciated!
Danny