3 ms·
I was once asked this exact question in a technical interview. I used __builtin_ctzll and that dumbfounded the interviewer. (Disclaimer: this may or may not be
by kccqzy 8y ago
I was once asked this exact question in a technical interview. I used __builtin_ctzll and that dumbfounded the interviewer. (Disclaimer: this may or may not be a good thing to do in an interview depending on the role/interviewer.)
In the real world, you probably want to use this builtin or something provided by the compiler/standard library as opposed to rolling your own.