Esempio n. 1
0
        public void IntFindBit()
        {
            using (var a = new HugeInt("0xA0000000000000000000800000000001"))
            {
                var max = Platform.Ui(ulong.MaxValue, uint.MaxValue);
                Assert.AreEqual(0UL, a.FindBit(true, 0));
                Assert.AreEqual(47UL, a.FindBit(true, 1));
                Assert.AreEqual(47UL, a.FindBit(true, 47));
                Assert.AreEqual(125UL, a.FindBit(true, 48));
                Assert.AreEqual(127UL, a.FindBit(true, 126));
                Assert.AreEqual(max, a.FindBit(true, 128));

                Assert.AreEqual(1UL, a.FindBit(false, 0));
                Assert.AreEqual(1UL, a.FindBit(false, 1));
                Assert.AreEqual(9UL, a.FindBit(false, 9));
                Assert.AreEqual(128UL, a.FindBit(false, 127));
                Assert.AreEqual(227UL, a.FindBit(false, 227));

                a.Value = ~a;

                Assert.AreEqual(0UL, a.FindBit(false, 0));
                Assert.AreEqual(47UL, a.FindBit(false, 1));
                Assert.AreEqual(47UL, a.FindBit(false, 47));
                Assert.AreEqual(125UL, a.FindBit(false, 48));
                Assert.AreEqual(127UL, a.FindBit(false, 126));
                Assert.AreEqual(max, a.FindBit(false, 128));

                Assert.AreEqual(1UL, a.FindBit(true, 0));
                Assert.AreEqual(1UL, a.FindBit(true, 1));
                Assert.AreEqual(9UL, a.FindBit(true, 9));
                Assert.AreEqual(128UL, a.FindBit(true, 127));
                Assert.AreEqual(227UL, a.FindBit(true, 227));
            }
        }
Esempio n. 2
0
        public void IntFindBit()
        {
            using (var a = new HugeInt("0xA0000000000000000000800000000001"))
            {
                var max = Platform.Ui(ulong.MaxValue, uint.MaxValue);
                Assert.AreEqual(0UL, a.FindBit(true, 0));
                Assert.AreEqual(47UL, a.FindBit(true, 1));
                Assert.AreEqual(47UL, a.FindBit(true, 47));
                Assert.AreEqual(125UL, a.FindBit(true, 48));
                Assert.AreEqual(127UL, a.FindBit(true, 126));
                Assert.AreEqual(max, a.FindBit(true, 128));

                Assert.AreEqual(1UL, a.FindBit(false, 0));
                Assert.AreEqual(1UL, a.FindBit(false, 1));
                Assert.AreEqual(9UL, a.FindBit(false, 9));
                Assert.AreEqual(128UL, a.FindBit(false, 127));
                Assert.AreEqual(227UL, a.FindBit(false, 227));

                a.Value = ~a;

                Assert.AreEqual(0UL, a.FindBit(false, 0));
                Assert.AreEqual(47UL, a.FindBit(false, 1));
                Assert.AreEqual(47UL, a.FindBit(false, 47));
                Assert.AreEqual(125UL, a.FindBit(false, 48));
                Assert.AreEqual(127UL, a.FindBit(false, 126));
                Assert.AreEqual(max, a.FindBit(false, 128));

                Assert.AreEqual(1UL, a.FindBit(true, 0));
                Assert.AreEqual(1UL, a.FindBit(true, 1));
                Assert.AreEqual(9UL, a.FindBit(true, 9));
                Assert.AreEqual(128UL, a.FindBit(true, 127));
                Assert.AreEqual(227UL, a.FindBit(true, 227));
            }
        }