How to write bits into a user-defined primitive type?

This topic might also be of interest (this isn’t the first time people have wanted to use a 24-bit primitive type):