public void RationalConstructorFromLongNegative()
        {
            var n = Platform.Si(-123456789123456, -1234567891);
            var d = Platform.Ui(12764787846358441471U, 2860486313U);

            using (var a = new HugeRational(n, d))
            {
                Assert.AreEqual(1, a.NumeratorNumberOfLimbsAllocated());
                Assert.AreEqual(-1, a.NumeratorNumberOfLimbsUsed());
                Assert.AreEqual(1, a.DenominatorNumberOfLimbsAllocated());
                Assert.AreEqual(1, a.DenominatorNumberOfLimbsUsed());
                Assert.AreEqual(n + "/" + d, a.ToString());
            }
        }
        public void RationalDispose()
        {
            var a = new HugeRational();

            a.Dispose();

            Assert.AreEqual(0, a.NumeratorNumberOfLimbsAllocated());
            Assert.AreEqual(0, a.NumeratorNumberOfLimbsUsed());
            Assert.AreEqual(IntPtr.Zero, a.NumeratorLimbs());

            Assert.AreEqual(0, a.DenominatorNumberOfLimbsAllocated());
            Assert.AreEqual(0, a.DenominatorNumberOfLimbsUsed());
            Assert.AreEqual(IntPtr.Zero, a.DenominatorLimbs());
        }
        public void RationalDefaultConstructor()
        {
            using (var a = new HugeRational())
            {
                Assert.AreNotEqual(0, a.NumeratorNumberOfLimbsAllocated());
                Assert.AreEqual(0, a.NumeratorNumberOfLimbsUsed());
                Assert.AreNotEqual(IntPtr.Zero, a.NumeratorLimbs());
                Assert.AreEqual("0", a.Numerator.ToString());

                Assert.AreNotEqual(0, a.DenominatorNumberOfLimbsAllocated());
                Assert.AreEqual(1, a.DenominatorNumberOfLimbsUsed());
                Assert.AreNotEqual(IntPtr.Zero, a.DenominatorLimbs());
                Assert.AreEqual("1", a.Denominator.ToString());
            }
        }
        public void RationalConstructorFromULong()
        {
            var n = Platform.Ui(ulong.MaxValue, uint.MaxValue);
            var d = Platform.Ui(12764787846358441471U, 2860486313U);

            using (var a = new HugeRational(n, d))
            {
                Assert.AreEqual(1, a.NumeratorNumberOfLimbsAllocated());
                Assert.AreEqual(1, a.NumeratorNumberOfLimbsUsed());
                Assert.AreEqual(1, a.DenominatorNumberOfLimbsAllocated());
                Assert.AreEqual(1, a.DenominatorNumberOfLimbsUsed());
                Assert.AreEqual(n.ToString(), a.Numerator.ToString());
                Assert.AreEqual(n.ToString() + "/" + d, a.ToString());
            }
        }
Exemplo n.º 5
0
        public void RationalDispose()
        {
            var a = new HugeRational();
            a.Dispose();

            Assert.AreEqual(0, a.NumeratorNumberOfLimbsAllocated());
            Assert.AreEqual(0, a.NumeratorNumberOfLimbsUsed());
            Assert.AreEqual(IntPtr.Zero, a.NumeratorLimbs());

            Assert.AreEqual(0, a.DenominatorNumberOfLimbsAllocated());
            Assert.AreEqual(0, a.DenominatorNumberOfLimbsUsed());
            Assert.AreEqual(IntPtr.Zero, a.DenominatorLimbs());
        }
Exemplo n.º 6
0
        public void RationalDefaultConstructor()
        {
            using (var a = new HugeRational())
            {
                Assert.AreNotEqual(0, a.NumeratorNumberOfLimbsAllocated());
                Assert.AreEqual(0, a.NumeratorNumberOfLimbsUsed());
                Assert.AreNotEqual(IntPtr.Zero, a.NumeratorLimbs());
                Assert.AreEqual("0", a.Numerator.ToString());

                Assert.AreNotEqual(0, a.DenominatorNumberOfLimbsAllocated());
                Assert.AreEqual(1, a.DenominatorNumberOfLimbsUsed());
                Assert.AreNotEqual(IntPtr.Zero, a.DenominatorLimbs());
                Assert.AreEqual("1", a.Denominator.ToString());
            }
        }
Exemplo n.º 7
0
        public void RationalConstructorFromULong()
        {
            var n = Platform.Ui(ulong.MaxValue, uint.MaxValue);
            var d = Platform.Ui(12764787846358441471U, 2860486313U);

            using (var a = new HugeRational(n, d))
            {
                Assert.AreEqual(1, a.NumeratorNumberOfLimbsAllocated());
                Assert.AreEqual(1, a.NumeratorNumberOfLimbsUsed());
                Assert.AreEqual(1, a.DenominatorNumberOfLimbsAllocated());
                Assert.AreEqual(1, a.DenominatorNumberOfLimbsUsed());
                Assert.AreEqual(n.ToString(), a.Numerator.ToString());
                Assert.AreEqual(n.ToString() + "/" + d, a.ToString());
            }
        }
Exemplo n.º 8
0
        public void RationalConstructorFromLongNegative()
        {
            var n = Platform.Si(-123456789123456, -1234567891);
            var d = Platform.Ui(12764787846358441471U, 2860486313U);

            using (var a = new HugeRational(n, d))
            {
                Assert.AreEqual(1, a.NumeratorNumberOfLimbsAllocated());
                Assert.AreEqual(-1, a.NumeratorNumberOfLimbsUsed());
                Assert.AreEqual(1, a.DenominatorNumberOfLimbsAllocated());
                Assert.AreEqual(1, a.DenominatorNumberOfLimbsUsed());
                Assert.AreEqual(n + "/" + d, a.ToString());
            }
        }