I seem to have found a bug in the BitVector32 structure.
Programatically, it is not possible to check the value of
the highest bit (32nd) using BitVector32.get_Item(int).
Setting the bit works as expected.
Example code (C#):
using System.Collections.Specialized;
BitVector32 vector = new BitVector32(0);
vector[1 << 31] = true;
vector[1 << 30] = true;
System.Console.WriteLine(System.Convert.ToString
(vector.Data, 16)); //"c0000000" as expected
System.Console.WriteLine(vector[1 << 30]); //"true" as
expected
System.Console.WriteLine(vector[1 << 31]); //"false", but
should be "true"
Mattias Sj?gren - 04 Dec 2003 19:45 GMT
Paul,
>I seem to have found a bug in the BitVector32 structure.
Yes, it has a bug in the handling of the high bit. It should be fixed
in v2.0.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Richard A. Lowe - 05 Dec 2003 13:21 GMT
Here's a replacement until then:
http://thetechnologist.is-a-geek.com/blog/PermaLink.aspx?guid=fa184c52-b602-4838
-95e1-00c7fca09d8d

Signature
C# jiggery-pokery:
http://blogs.geekdojo.net/Richard
> I seem to have found a bug in the BitVector32 structure.
> Programatically, it is not possible to check the value of
[quoted text clipped - 17 lines]
> System.Console.WriteLine(vector[1 << 31]); //"false", but
> should be "true"
Sebastien Lambla - 11 Dec 2003 12:29 GMT
Any comments on this class to improove it are welcomed btw :)

Signature
Sebastien Lambla
http://thetechnologist.is-a-geek.com/blog/
> Here's a replacement until then:
http://thetechnologist.is-a-geek.com/blog/PermaLink.aspx?guid=fa184c52-b602-4838
-95e1-00c7fca09d8d
> > I seem to have found a bug in the BitVector32 structure.
> > Programatically, it is not possible to check the value of
[quoted text clipped - 17 lines]
> > System.Console.WriteLine(vector[1 << 31]); //"false", but
> > should be "true"
Ryan Byington - 08 Dec 2003 18:23 GMT
This is a known bug in V1.1 and it has been fixed for the next version. It
seems that we were not correctly handling the negative indexer on get. This
should only impact an index with the highest order bit set. Beside the
posted solution you could do something like the following:
public class MyBitVector32
{
BitVector32 vector;
public MyBitVector32(int data)
{
vector = new BitVector32(data);
}
public bool this[int bit]
{
get {
return (((uint)vector.Data) & bit) == (uint)bit;
}
set {
vector[bit] = value;
}
}
public int Data
{
get {
return vector.Data;
}
}
}
Then implement any other members you need on BitVector32 that just call
into vector. This should make switching to BitVector32 when we relase the
next version easier (all you should have to do is replace all instances of
MyBitVector32 with BitVector32)
Ryan Byington [MS]
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--------------------
| Content-Class: urn:content-classes:message
| From: "Paul Reeder" <paul@reeder.ws>
[quoted text clipped - 37 lines]
| System.Console.WriteLine(vector[1 << 31]); //"false", but
| should be "true"