Search code examples
c#intexponential

convert very big exponential to decimal in c#


5.35754303593134E+300 to 53575430359313400000000000000000000 ... 000000000

Can anyone do this because this number is very large?

I have tried:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            double s = double.Parse((System.Math.Pow(2, 999)).ToString(), System.Globalization.NumberStyles.Float);
            Console.WriteLine("value={0}", s);
            Console.ReadKey();
        }
    }
}

Solution

  • Do one of the following,

    Console.WriteLine(s.ToString("N0")); //comma separated
    Console.WriteLine(s.ToString("F0")); 
    

    Both works.