Advogato blog for fejjAdvogato blog for fejj1 Feb 2007- February 1, 2007 fzort: Ah, thank you for the explanation :) I was just about to note that expanding on my previous estimation, a slightly better one would be: r = (x >> 1) - (x >> 2) - (x >> 3) + (x >> 6) And then of course I could perhaps expand on the (x >> 6) in a similar fashion to get an even more accurate result. Anyways... kind of an interesting problem.http://www.advogato.org/person/fejj/diary.html?start=173 1 Feb 2007- February 1, 2007 Interesting interview questions: Q: What's a fast way to divide an integer by 7 using the bit shift operator (apparently asked by an EA Sports interviewer) A: I thought about this for a bit and came up with the following estimation: r = (x >> 2) - (x >> 3) + (x >> 6); I mostly mention this because I had my own interview today where I felt... well, less than adequate. Suffice it to say, my ability to figure out the Big-O notation for algorithms was less than stellar. I.http://www.advogato.org/person/fejj/diary.html?start=172 |