Example #1
0
 public void RationalInputOutputRaw()
 {
     using (var a = new HugeRational("0x10123456789ABCDEF0123456789ABCDEF0123456789ABCDEF/361720912810755408215708460645842859722715865206816237944587"))
     using (var b = new HugeRational())
     using (var ms = new MemoryStream())
     {
         a.Value = a ^ 100;
         a.Write(ms);
         ms.Position = 0;
         b.Read(ms);
         Assert.AreEqual(a, b);
         Assert.AreEqual(ms.Length, ms.Position);
     }
 }
Example #2
0
 public void RationalInputOutputRaw()
 {
     using (var a = new HugeRational("0x10123456789ABCDEF0123456789ABCDEF0123456789ABCDEF/361720912810755408215708460645842859722715865206816237944587"))
         using (var b = new HugeRational())
             using (var ms = new MemoryStream())
             {
                 a.Value = a ^ 100;
                 a.Write(ms);
                 ms.Position = 0;
                 b.Read(ms);
                 Assert.AreEqual(a, b);
                 Assert.AreEqual(ms.Length, ms.Position);
             }
 }
Example #3
0
        public void RationalInputOutputStr()
        {
            using (var a = new HugeRational("0x10123456789ABCDEF0123456789ABCDEF0123456789ABCDEF/361720912810755408215708460645842859722715865206816237944587"))
            using (var b = new HugeRational())
            using (var ms = new MemoryStream())
            {
                a.Value = a ^ 100;
                using (var writer = new StreamWriter(ms, Encoding.UTF8, 1024, true))
                    a.Write(writer);

                ms.Position = 0;

                using (var reader = new StreamReader(ms, Encoding.UTF8, false, 1024, true))
                    b.Read(reader);

                Assert.AreEqual(a, b);
                Assert.AreEqual(ms.Length, ms.Position);
            }
        }
Example #4
0
        public void RationalInputOutputStr()
        {
            using (var a = new HugeRational("0x10123456789ABCDEF0123456789ABCDEF0123456789ABCDEF/361720912810755408215708460645842859722715865206816237944587"))
                using (var b = new HugeRational())
                    using (var ms = new MemoryStream())
                    {
                        a.Value = a ^ 100;
                        using (var writer = new StreamWriter(ms, Encoding.UTF8, 1024, true))
                            a.Write(writer);

                        ms.Position = 0;

                        using (var reader = new StreamReader(ms, Encoding.UTF8, false, 1024, true))
                            b.Read(reader);

                        Assert.AreEqual(a, b);
                        Assert.AreEqual(ms.Length, ms.Position);
                    }
        }