• 0

[c#] Conversion Problem


Question

I have this problem:

string input = Console.ReadLine();

Int64 stuff = Convert.ToInt64(input);

Console.WriteLine(stuff);

But, when i put in 98753798259782537908298702539780253907823

I get an error saying that there are too many integers in it.

How do I edit this so I can have as many integers as I want in it?

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Int64 (aliased in C# as the data type 'long') has an allowable range of -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

Link to comment
Share on other sites

  • 0

If you want to hold the largest possible numbers, use a double. Its range is ?5.0 ? -324p> to ?1.7 ?308sup>. You only get 15-16 digits precision though.

I don't think that in C# there's the equivalent of a truly unlimited integral type, like in Python. I don't think you should need one, anyway.

Link to comment
Share on other sites

  • 0
If you want to hold the largest possible numbers, use a double. Its range is ?5.0 ? -324p> to ?1.7 ?308sup>. You only get 15-16 digits precision though.

I don't think that in C# there's the equivalent of a truly unlimited integral type, like in Python. I don't think you should need one, anyway.

That's because Python does integer manipulation a different way, it has a builtin big integer library so to speak. You can get one for C# if you want.

http://www.codeplex.com/IntX/

Visual Studio 2010 will ship with .NET 4.0 which includes Microsoft's own implementation of a BigInt library.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.