public void bspow2() { for (var i = 0; i <= 231; i++) { var bs = BitString.FromPow2(i); Claim.eq((int)bs.Length, i + 1); for (var j = 0; j < bs.Length; j++) { if (j != bs.Length - 1) { Claim.eq(bs[j], Bit.Off); } else { Claim.eq(bs[j], Bit.On); } } if (i <= 63) { var val1 = Pow2.pow((byte)i); var val2 = bs.TakeValue <ulong>(); Claim.eq(val1, val2); } } }
public void pack_splits() { var src = Random.Span <ulong>(Pow2.T11); foreach (var x in src) { (var x0, var x1, var x2, var x3, var x4, var x5, var x6, var x7) = Bits.split(x, new N8()); for (var i = 0; i < 8; i++) { var dst = (byte)0; var pos = (byte)(Pow2.pow(i) - 1); Bits.pack(in x0, in x1, in x2, in x3, in x4, in x5, in x6, in x7, pos, ref dst); var j = 0; Claim.yea(gbits.match(dst, j++, x0, pos)); Claim.yea(gbits.match(dst, j++, x1, pos)); Claim.yea(gbits.match(dst, j++, x2, pos)); Claim.yea(gbits.match(dst, j++, x3, pos)); Claim.yea(gbits.match(dst, j++, x4, pos)); Claim.yea(gbits.match(dst, j++, x5, pos)); Claim.yea(gbits.match(dst, j++, x6, pos)); Claim.yea(gbits.match(dst, j++, x7, pos)); } } }
public void bs_wordgen() { var wordLen = 8; var wordCount = Pow2.pow(wordLen); var words = BinaryLanguage.Get().Words(wordLen).ToArray(); Claim.eq(wordCount, words.Length); iter(words, w => Claim.eq(wordLen, w.Format().Length)); for (var i = 0u; i < wordCount; i++) { var w = words[i]; var value = w.TakeValue <byte>(); Claim.eq(i, value); } }