5 ms·
My goto would have been multiplication by (1/7)*2^16 followed by a right shift. You still need to verify the constant (or can add another after the multiply) to
by phkahler 4y ago
My goto would have been multiplication by (1/7)*2^16 followed by a right shift. You still need to verify the constant (or can add another after the multiply) to get it to work in every case. Used this once to extract digits of a 16bit integer from left to right.
- eru 4y agoYour C compiler will do this for you automatically. See eg https://godbolt.org/z/3Yqbceaza https://godbolt.org/z/3Yqbceaza (I don't know what language is used here. I'm just assuming something like C.)