I am trying to do a short simulation where I need a small bit array and I selected System.Collections.Specialized.BitVector32.
I run it inside a single-threaded object in a single-threaded loop about 1,000,000 times, each time for indices {0,1,2}.
Here is the code:
private System.Collections.Specialized.BitVector32 currentCalc
= new System.Collections.Specialized.BitVector32();
private void storeInCurrent(int idx, bool val)
{
currentCalc[idx] = val;
if (currentCalc[idx] != val)
{
throw new Exception("Inconceivable!");
}
}
As far as I understand, an exception should not be thrown, but sometimes it happens! An exception is not thrown every time, but in an honest percentage - CONSTANT 1/6 of the time! (which is even stranger)
What am I doing wrong?
source
share