This is ugly. You should be using `np.uint32_t` instead of `unsigned int`, which will do all this masking for you.