Linkedin Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: Phone Interview
hi can you please share the reason behind above being a very bad code. What is wrong with that code? I too came up with a similar solution so I would like to know, where are we going wrong?
Given a number
n = 2^m + x1*2^(m-1) + ...... xm*2^0 + (x(m+1))*2^-1 + ......
Must have
2^m <= n < 2^(m+1)
So
m <= log(2)n < m+1
m is the digit that the highest 1 appears in binary of n no matter n is integer or float.
By the way, Bitwise seems not apply to float in the scope of C/C++. I'm wondering the question implies we should only focus on integers.
You such a bad interviewer and hopefully the interviewee wasn't going to work with you as well.
- Anonymous January 09, 2013