Ejemplo n.º 1
0
        private static void ListAllBigIntegerFiles()
        {
            foreach (var file in Directory.EnumerateFiles(
                         Directory.GetCurrentDirectory(), "*.big", SearchOption.TopDirectoryOnly))
            {
                File.Delete(file);
            }

            var tasks = new List <Task>();

            for (var i = 0; i < Environment.ProcessorCount * 2; i++)
            {
                tasks.Add(Task.Factory.StartNew(() =>
                {
                    var data = NumberGenerator.CreateBigIntegerWithLotsOfInformation(100);
                    File.WriteAllLines(data.Item3.ToString("N") + ".big", new string[] { data.Item1.ToString() });
                }));
            }

            Task.WaitAll(tasks.ToArray());

            foreach (var file in Directory.EnumerateFiles(
                         Directory.GetCurrentDirectory(), "*.big", SearchOption.TopDirectoryOnly))
            {
                Console.Out.WriteLine(file);

                foreach (var line in File.ReadLines(file))
                {
                    Console.Out.WriteLine(line);
                }
            }
        }
Ejemplo n.º 2
0
        private static void CreateInformationRichBigInteger()
        {
            var xInfo = NumberGenerator.CreateBigIntegerWithLotsOfInformation(50);

            Console.Out.WriteLine("Item1 = " + xInfo.Item1);
            Console.Out.WriteLine("Item2 = " + xInfo.Item2.ToString("R"));
            Console.Out.WriteLine("Item3 = " + xInfo.Item3);
        }