News for hackers. Stuff that matters.
Re:Write A Function To Determine If A Number Is A Power Of 2 by nevinera on Monday October 18, 2010 @12:26PM (#1804083)
Expecting the bit arithmetic would be for some positions. But asking a programmer to design and implement an extremely basic algorithm doesn't seem unreasonable to me.
Re:Write A Function To Determine If A Number Is A Power Of 2 by BigZaphod on Monday October 18, 2010 @12:31PM (#1804109)
I guess I was focusing on the bit-level answers since that's what the article and most of the comments seem to value the highest.

You're right, though, the original question itself is not so much of a problem, I suppose. What bothered me is the subtext that, unless you get down to the bit level with the minimum possible number of CPU instructions in the result and do the compiler's job yourself, you're not a "real programmer" or something.

Re:Write A Function To Determine If A Number Is A Power Of 2 by leif on Monday October 18, 2010 @12:38PM (#1804140)
I disagree. A "real programmer" should know something about how the computer works, and should not revere anything below his level as "magic" or be afraid of it, even if he/she will never need to deal with it. Understanding that integers are stored as binary bitstrings, and what this means, is the most basic level of competency in this area.