Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

26
  • 23
    Instead of dividing by 2 and commenting it as "shift bits...", you should just use the shift operator (>>) and leave out the comment. Commented Sep 25, 2008 at 3:42
  • 13
    wouldn't it make more sense to replace if ((value & 1) == 1) { count++; } with count += value & 1? Commented Apr 25, 2010 at 19:04
  • 29
    No, the best solution isn't the one most readable in this case. Here the best algorithm is the fastest one. Commented Sep 23, 2010 at 7:55
  • 26
    That's entirely your opinion, @nikic, although you're free to downvote me, obviously. There was no mention in the question as to how to quantify "best", the words "performance" or "fast" can be seen nowhere. That's why I opted for readable. Commented Sep 23, 2010 at 8:57
  • 4
    I made it quite clear that the answer was heavily based on my opinions and preferences, and I saw little need to rehash the performance-based answers already in play. Earlier comments have alredy covered this ground and, apparently, 172 people agreed though, admittedly, that's four fifths of bugger-all of the SO community so may not carry that much weight :-) Bottom line, I have no issue with the way you vote, I just wanted to make sure you et al at least understood why I gave the answer I gave. You may have the last word if you wish, I think I've explained as best I can. Commented Mar 2, 2018 at 1:45