clong-integermultiprecision

Is it possible to store 2 32-bit values in one long int variable?


I want to store two 32-bit values in a single long int variable.

How would you do this on a 32-bit OS using C? Is it possible to store the data in a single long long variable? If so, how is that done?


Solution

  • Assuming a long is 64 bits on your platform,

    int v1 = 123;
    int v2 = 456;
    long val = v1 << 32 | v2;