[Mono-list] [PATCH] BitVector32
Mon, 24 Jun 2002 11:05:03 -0700
Ah, bit twiddling ;-)
private static int NumberOfSetBits (uint i)
i = (i & 0x55555555) + ((i & 0xaaaaaaaa) >> 1);
i = (i & 0x33333333) + ((i & 0xcccccccc) >> 2);
i = (i & 0x0f0f0f0f) + ((i & 0xf0f0f0f0) >> 4);
i = (i & 0x00ff00ff) + ((i & 0xff00ff00) >> 8);
i = (i & 0x0000ffff) + ((i & 0xffff0000) >> 16); return
From: Andrew Birkett [mailto:firstname.lastname@example.org]
Sent: Monday, June 24, 2002 4:21 AM
Subject: Re: [Mono-list] [PATCH] BitVector32
I've got a few mono patches lined up today. I did a big cycle ride on
Saturday and didn't want to move on Sunday so I got lots of coding done!
I've attached a further patch for BitVector32, created against the
current cvs version. The patch contains:
- Unit test for section indexers
- Check for >32 bits when creating sections
- Factored out helper methods for bit twiddling operations.
- Removed ^M's from BitVector32Test.cs
Unit tests pass, except those which were already broken prior to my
changes. The failures are all in date/time classes, due to me being in
the GMT time zone. I'll have a look at fixing those later.
- www.tardis.ed.ac.uk/~adb -