Originally Posted by SuperKoko
For signed bit-fields, this is implementation-dependent.
Indeed, conversions from integer types to signed bit-fields give implementation-defined results, or raise an implementation-defined signal if the value can't be preserved.
On the other hand, integer overflow has undefined behavior.
A 16 bits unsigned bit-field will behave like a 16 bits unsigned integer (i.e. an unsigned integer having 16 value bits and 0 or more padding bits).
You can use it safely for unsigned bit-fields.
For signed bit-fields, this isn't a great idea since results will be implementation-dependent.
And, if you fear portability issues, you can use the % operator.