Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / December 2003

Tip: Looking for answers? Try searching our database.

Bug in System.Collections.Specialized.BitVector32

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul Reeder - 04 Dec 2003 17:57 GMT
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"

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.