示例#1
0
        public void IntGetBit()
        {
            using (var a = new HugeInt("0xA000000000000000000200000000001"))
            {
                var limbs = 128 / MpirSettings.BITS_PER_LIMB;

                Assert.IsTrue(a.GetBit(45));
                Assert.IsFalse(a.GetBit(46));
                Assert.AreEqual(limbs, a.NumberOfLimbsUsed());
                Assert.AreEqual(limbs + 1, a.NumberOfLimbsAllocated());
                Assert.IsFalse(a.GetBit(246));
                Assert.AreEqual(limbs, a.NumberOfLimbsUsed());
                Assert.AreEqual(limbs + 1, a.NumberOfLimbsAllocated());
                a.Value = ~a;
                Assert.AreEqual(-limbs, a.NumberOfLimbsUsed());
                Assert.AreEqual(limbs + 1, a.NumberOfLimbsAllocated());
                Assert.IsTrue(a.GetBit(246));
                Assert.AreEqual(-limbs, a.NumberOfLimbsUsed());
                Assert.AreEqual(limbs + 1, a.NumberOfLimbsAllocated());
            }
        }
示例#2
0
文件: Bitwise.cs 项目: wbhart/mpir
        public void IntGetBit()
        {
            using (var a = new HugeInt("0xA000000000000000000200000000001"))
            {
                var limbs = 128 / MpirSettings.BITS_PER_LIMB;

                Assert.IsTrue(a.GetBit(45));
                Assert.IsFalse(a.GetBit(46));
                Assert.AreEqual(limbs, a.NumberOfLimbsUsed());
                Assert.AreEqual(limbs + 1, a.NumberOfLimbsAllocated());
                Assert.IsFalse(a.GetBit(246));
                Assert.AreEqual(limbs, a.NumberOfLimbsUsed());
                Assert.AreEqual(limbs + 1, a.NumberOfLimbsAllocated());
                a.Value = ~a;
                Assert.AreEqual(-limbs, a.NumberOfLimbsUsed());
                Assert.AreEqual(limbs + 1, a.NumberOfLimbsAllocated());
                Assert.IsTrue(a.GetBit(246));
                Assert.AreEqual(-limbs, a.NumberOfLimbsUsed());
                Assert.AreEqual(limbs + 1, a.NumberOfLimbsAllocated());
            }
        }