/// <summary>Iterate over the bits in the range</summary> public static IEnumerable <int> EnumBitSeq(this ulong x, int start, int count, bool low_to_high = true) { for (int i = 0; i != count; ++i) { yield return(x.BitAt(start + (low_to_high ? i : count - 1 - i))); } }
public void Test_BitAt() { for (int i = 0; i < LOOP_COUNT; i++) { Debug.Assert(TEST_VALUE.BitAt(i) == EXPTECTED_BITS[i]); } }
public static string BitString(this ulong value) { #pragma warning disable XS0001 // Find APIs marked as TODO in Mono var stringBuilder = new System.Text.StringBuilder(64); #pragma warning restore XS0001 // Find APIs marked as TODO in Mono for (int i = 63; i >= 0; i--) { stringBuilder.Append(value.BitAt(i)); } return(stringBuilder.ToString()); }