From: david jacques on 21 Sep 2009 10:34 Hi there, How did you come up with the values: 0xe994 14 3 in the CountBits(int value) method. They are hard coded and dont have any equation that can explain it. If you can that would be excellent :) *** Sent via Developersdex http://www.developersdex.com ***
From: Göran Andersson on 23 Sep 2009 08:56 david jacques wrote: > Hi there, > > How did you come up with the values: > 0xe994 > 14 > 3 > > in the CountBits(int value) method. > > They are hard coded and dont have any equation that can explain it. > > If you can that would be excellent :) The value 0xe994 is just a bit mask: 11 01 10 01 10 01 01 00 Each two bits represent the number of bits in a three bit value. The method chops the value up in three bit chunks and adds up the number of bits in each chunk. 14 is 7 times 2, i.e. the three lower bits multiplied by 2 to get an index to a pair of bits in the bit mask. -- G�ran Andersson _____ http://www.guffa.com
|
Pages: 1 Prev: Function param expects IEnumerable<ClassName> Next: Lambda Expression |