Ian Collins <(E-Mail Removed)> writes:

>

>> --8<---------------cut here---------------start------------->8---

>> long intsToLong(int x, int y)

>> {

>> long tmp = x;

>> tmp<<= int_bits;

>> tmp += y;

>> return tmp;

>> }

>>

>> void longToInts(long l)

>> {

>> int second = l>> int_bits;

>> long mask = (2>> (int_bits + 1)) - 1;

>

> Have you by any chance looked at the value of mask? Hint - what is 2

> left shifted 31 places?
Yes sure I was shifting in the wrong direction, thanks

So and what if the size of the types is not multiple of each other?

For example type X is 6 bytes and type Y is 4 bytes.

Then what is the best way to pack data from one type to the other?