コード例 #1
0
        public void pack_4x32()
        {
            var src = Random.Span <uint>(SampleSize);

            foreach (var x in src)
            {
                (var x0, var x1, var x2, var x3) = Bits.split(x, new N4());
                var y = Bits.pack(x0, x1, x2, x3);
                Claim.eq(x, y);
                Claim.eq(x, BitConverter.ToUInt32(new byte[] { x0, x1, x2, x3 }));
            }

            {
                var xval = 0b10100111001110001110010110101000;
                var x0   = (byte)0b10101000;
                var x1   = (byte)0b11100101;
                var x2   = (byte)0b00111000;
                var x3   = (byte)0b10100111;
                Claim.eq(xval, Bits.pack(x0, x1, x2, x3));

                var bsExpect = "10100111001110001110010110101000";
                var bsActual = xval.ToBitString().Format();
                Claim.eq(bsExpect, bsActual);

                var bsAssembly = BitString.Assemble("10101000", "11100101", "00111000", "10100111").Format();
                Claim.eq(bsExpect, bsAssembly);
            }
        }