Steve Hebert's Development Blog

.Steve's .Blog

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


Navigation

Blogs I Follow

Favorite Tools

Development Articles

Subscriptions

Post Categories

Article Categories



Sunday, October 24, 2004 - Posts

Bit Counting Code Test - In one line!

My hat goes off to Adrian Florea for his one line solution to the bit counting test:

System.Convert.ToString(value, 2).Replace("0", string.Empty).Length

I hadn't considered this approach, I've always iterated through the byte testing the on bits.  That's a cool way to look at the problem and a nice use of the framework!

 

posted Sunday, October 24, 2004 7:18 PM by sdhebert




Powered by Dot Net Junkies, by Telligent Systems