Hacker News new | ask | show | jobs
by phkahler 1201 days 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.
1 comments

Your C compiler will do this for you automatically. See eg https://godbolt.org/z/3Yqbceaza

(I don't know what language is used here. I'm just assuming something like C.)