5 ms·
How is a disguised return 0 anything remotely resembling a good question? I highly suspect most people who are "unable to answer" are actually just misunderstan
by pcwalton 7y ago
How is a disguised return 0 anything remotely resembling a good question? I highly suspect most people who are "unable to answer" are actually just misunderstanding the question, since it's phrased in such a bizarre way. The way you phrased it, I'm not even 100% sure that "return 0" is the answer you're looking for!
- ghaff 7y agoThat’s the right return value of course but ignoring everything else doesn’t actually meet the requirements of the question. Of course in a live situation you can ask if that’s ok or if they actually want useless bit twiddling.
- pcwalton 7y agoBut there's no such thing, semantically, as "leaving zero bits alone". The value 0 has no notion of "where it came from". The expression "x & 0" is semantically equivalent to the expression "0", in that they represent the same value. In my view, the fact that the question even lends itself to philosophical debate like this just illustrates how exceptionally bad the question is, even by Google standards.
- ghaff 7y agoOh I don’t disagree. Literally going through bit by bit and zeroing any bit not equal to zero would be grossly inefficient especially if you know it’s unnecessary.
- lonelappde 7y agoIt's not grossly inefficient to do 64 iterations of an arithmetic loop for a trick toy function that has no reason to ever be called in practice.
- dmitrygr 7y agoIt is a warm up meant to take 20 seconds. Before we get to something actually meaningful