Beispiel #1
0
        public void SetBit()
        {
            string AsString;

            using mpz_t a = new mpz_t("A0000000000000000000200000000001", 16);
            AsString      = a.ToString(16).ToUpper();
            Assert.AreEqual("A0000000000000000000200000000001", AsString);

            a.SetBit(47);
            AsString = a.ToString(16).ToUpper();
            Assert.AreEqual("A0000000000000000000A00000000001", AsString);

            a.SetBit(47);
            AsString = a.ToString(16).ToUpper();
            Assert.AreEqual("A0000000000000000000A00000000001", AsString);

            a.ClearBit(45);
            AsString = a.ToString(16).ToUpper();
            Assert.AreEqual("A0000000000000000000800000000001", AsString);

            a.ClearBit(45);
            AsString = a.ToString(16).ToUpper();
            Assert.AreEqual("A0000000000000000000800000000001", AsString);

            a.ClearBit(131);
            AsString = a.ToString(16).ToUpper();
            Assert.AreEqual("A0000000000000000000800000000001", AsString);

            a.SetBit(131);
            AsString = a.ToString(16).ToUpper();
            Assert.AreEqual("8A0000000000000000000800000000001", AsString);
        }