[Issue 4717] std.bitmanip.BitArray changes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 24 00:33:52 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4717


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug at yahoo.com.au


--- Comment #2 from Don <clugdbug at yahoo.com.au> 2010-08-24 00:33:44 PDT ---
(In reply to comment #0)
> - The count() is also known known as Population or Hamming weight. This is
> useful for Hamming distances, to count bits in many situations, like for
> example for the Sieve of Eratosthenes. There are ways and refined algorithms to
> speed up this operation a lot. And this is a very commonly useful operation. I
> may offer some D code if you want. See also:
> http://en.wikipedia.org/wiki/Hamming_weight
> http://graphics.stanford.edu/~seander/bithacks.html
> And see also the __builtin_popcount() built-in function of GCC.

Curious fact: the built-in popcount instruction isn't much use for bit arrays.
It's great for 64 bit longs (especially for chess programs!) but once you have
a dozen machine words or more, it's faster to add the bits sideways. An
interesting consequence of this is that Intel/AMD's new popcount instruction is
hardly ever useful...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list