Пример #1
0
        public void bitblock32_spans()
        {
            var x = BitBlock32.Alloc();

            x.Bit0  = 1;
            x.Bit5  = 1;
            x.Bit19 = 1;
            var y = BitBlock.AsSpan(ref x);

            Claim.eq(y[0], x.Bit0);
            Claim.eq(y[5], x.Bit19);

            Claim.eq(x[0], (byte)1);
            Claim.eq(x[5], (byte)1);
            Claim.eq(x[19], (byte)1);

            for (var i = 0; i < SampleSize; i++)
            {
                var src      = Random.Span <byte>(Pow2.T05);
                var dstBlock = BitBlock32.FromSpan(src);
                for (var j = 0; j < src.Length; j++)
                {
                    Claim.eq(src[j], dstBlock[j]);
                }

                var dstSpan = BitBlock.AsSpan(ref dstBlock);
                for (var j = 0; j < dstSpan.Length; j++)
                {
                    Bits.toggle(ref dstSpan[j], 0);
                    Claim.neq(dstBlock[j], src[j]);
                }
            }
        }
Пример #2
0
 public uint ToUInt32()
 => BitBlock.AsSpan(ref this).TakeUInt32();
Пример #3
0
        public static Span <byte> part32x1(uint src)
        {
            BitBlock32 block = default;

            return(BitBlock.AsSpan(ref part32x1(src, ref block)));
        }
Пример #4
0
 public ulong ToUInt64()
 => BitBlock.AsSpan(ref this).TakeUInt64();