This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

compose a Long of two Ints

Hello Forum,
I want to compose two int variables, which contains the LSW and MSW, respective, into one unsigned long variable.
The following code does the right thing:

int lo, hi;
unsigned long longvar;
longvar = (unsigned long) (unsigned int) hi << 16 | (unsigned long) (unsigned int) lo;
But the compiled code is rather complicated. Are there possiblities to do this more straightforward (beside the use of an union)?
Something like
longvar.msw = hi;
longvar.lsw = lo;
?
Thanks for all hints and tips - Peter

0