How to cast signed int to 15 bit bit-field?

Viewed 3075

I have some bitfield:

int somefield : 15;

I'm trying to convert an int to 15 bit (can be positive or negative).

What is the best practice to do it efficiently?

2 Answers
Related