Exemple #1
0
        public void SubtractionTest()
        {
            CNumber_Integer_Accessor target = new CNumber_Integer_Accessor();
            CNumber_Integer          other  = new CNumber_Integer(0.0);

            target.FromString("0x5");
            other.FromString("0x7");
            target.Subtraction(other);
            Assert.AreEqual("-0x2", target.AsString);

            target.FromString("0x1.0000.0005");
            other.FromString("0x7");
            target.Subtraction(other);
            Assert.AreEqual("0xFFFF.FFFE", target.AsString);

            target.FromString("0x1.0000.0005");
            other.FromString("0x1.0000.0007");
            target.Subtraction(other);
            Assert.AreEqual("-0x2", target.AsString);

            target.FromString("0x7");
            other.FromString("0x1.0000.0005");
            target.Subtraction(other);
            Assert.AreEqual("-0xFFFF.FFFE", target.AsString);

            target.FromString("0x1.0000.0000.0000.0005");
            other.FromString("0x1.0000.0007");
            target.Subtraction(other);
            Assert.AreEqual("0xFFFF.FFFE.FFFF.FFFE", target.AsString);
        }
Exemple #2
0
        public void AdditionTest1()
        {
            CNumber_Integer_Accessor target = new CNumber_Integer_Accessor();

            target.FromString("0xFFFFFFFE");
            target.Addition(7);
            Assert.AreEqual("0x1.0000.0005", target.AsString);
        }
Exemple #3
0
        public void AdditionTest()
        {
            CNumber_Integer_Accessor target = new CNumber_Integer_Accessor();
            CNumber_Integer          other  = new CNumber_Integer(0.0);

            target.FromString("0x5");
            other.FromString("0x7");
            target.Addition(other);
            Assert.AreEqual("0xC", target.AsString);

            target.FromString("0xFFFFFFFE");
            other.FromString("0x7");
            target.Addition(other);
            Assert.AreEqual("0x1.0000.0005", target.AsString);

            target.FromString("0xFFFFFFFE");
            other.FromString("0x100000007");
            target.Addition(other);
            Assert.AreEqual("0x2.0000.0005", target.AsString);

            target.FromString("0x1FFFFFFFE");
            other.FromString("0x100000007");
            target.Addition(other);
            Assert.AreEqual("0x3.0000.0005", target.AsString);

            target.FromString("0xFFFFFFFFFFFFFFFE");
            other.FromString("0x7");
            target.Addition(other);
            Assert.AreEqual("0x1.0000.0000.0000.0005", target.AsString);

            target.FromString("0x1.FFFF.FFFF.FFFF.FFFE");
            other.FromString("0x7");
            target.Addition(other);
            Assert.AreEqual("0x2.0000.0000.0000.0005", target.AsString);

            target.FromString("0x7");
            other.FromString("0x1.FFFF.FFFF.FFFF.FFFE");
            target.Addition(other);
            Assert.AreEqual("0x2.0000.0000.0000.0005", target.AsString);

            target.FromString("0x1.FFFF.FFFF.FFFF.FFFE");
            other.FromString("0x1.0000.0007");
            target.Addition(other);
            Assert.AreEqual("0x2.0000.0001.0000.0005", target.AsString);

            target.FromString("0x1.FFFF.FFFE.FFFF.FFFE");
            other.FromString("0x1.0000.0007");
            target.Addition(other);
            Assert.AreEqual("0x2.0000.0000.0000.0005", target.AsString);
        }
Exemple #4
0
        public void ToStringTest()
        {
            CNumber_Integer_Accessor target = new CNumber_Integer_Accessor();
            string a = "0x1.0000.0000";

            target.FromString(a);
            string b = target.ToString(16);

            Assert.AreEqual(a, b);
        }
Exemple #5
0
        public void ShiftLeftTest()
        {
            CNumber_Integer_Accessor target = new CNumber_Integer_Accessor("0x1000.0000");
            uint actual = target.ShiftLeft(4);

            Assert.AreEqual("0x1.0000.0000", target.AsString);
            Assert.AreEqual((uint)1, actual);

            target.FromString("0x1");
            actual = target.ShiftLeft(32);
            Assert.AreEqual("0x1.0000.0000", target.AsString);
            Assert.AreEqual((uint)0, actual);
        }