Esempio n. 1
0
 /// <summary>
 /// Provides access to the internal binary encoding.
 /// </summary>
 /// <param name="pos">The bit index</param>
 /// <returns>The state of the indexed bit</returns>
 public bool this[int pos]
 {
     get
     {
         int    widx = pos / 32;
         int    bidx = pos % 32;
         uint[] digits;
         bool   neg;
         _value.GetInternalState(out digits, out neg);
         if (widx >= digits.Length)
         {
             return(false);
         }
         else
         {
             return((digits[widx] & (1 << bidx)) != 0);
         }
     }
     set
     {
         int    widx = pos / 32;
         int    bidx = pos % 32;
         uint[] digits;
         bool   neg;
         _value.GetInternalState(out digits, out neg);
         if (widx < digits.Length)
         {
             if (value)
             {
                 digits[widx] |= (uint)(1 << bidx);
             }
             else
             {
                 digits[widx] &= (uint)~(1 << bidx);
             }
             _value = new IntX(digits, neg);
         }
         else if (value)
         {
             _value += (new IntX(1) << pos);
         }
     }
 }