Data types

Hi! I need a little bit of help.

If I have a variable ‘x’ that is declared as a long int, but I need to read only the 16 less significant bits, how could I do this?

Thank you

you need to use a cast e.g.

long int x;
int y;

y = (int)x;

Regards,
Peter

Thank you!

And, is there a way to read only the most significant bits of the same variable?

y = (int)(x >> 16);

Thank you very much!