code_ninja Posted April 8, 2009 Share Posted April 8, 2009 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 More sharing options...
0 Antaris Veteran Posted April 8, 2009 Veteran Share Posted April 8, 2009 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 More sharing options...
0 code_ninja Posted April 8, 2009 Author Share Posted April 8, 2009 So what you're saying is that I neet to enter data less than 9223372036854775807? Link to comment Share on other sites More sharing options...
0 deep1234 Posted April 8, 2009 Share Posted April 8, 2009 yes, less 9223372036854775807 and bigger than -9223372036854775807. Link to comment Share on other sites More sharing options...
0 code_ninja Posted April 8, 2009 Author Share Posted April 8, 2009 thanx guys! Link to comment Share on other sites More sharing options...
0 Andre S. Veteran Posted April 8, 2009 Veteran Share Posted April 8, 2009 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 More sharing options...
0 Tech God Posted April 13, 2009 Share Posted April 13, 2009 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 More sharing options...
0 vks87 Posted April 16, 2009 Share Posted April 16, 2009 Thanks guys for this useful posts..this is really a interesting and knowledgeable post for me... Link to comment Share on other sites More sharing options...
Question
code_ninja
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