-
October 11th, 2014, 09:54 AM
#1
Integral constant is too large: How to put a thousand 50-digits integers in an array?
Hello.
I'm using the software SharpDevelop (C#).
I've created a list of integers (array) like this:
int[] name = new int[number-of-elements]{elements-separated-by-commas}
In the {} I would like to put 1000 integers, half of those having more than 50 digits.
But when I do that I get the following error:
"Integral constant is too large (CS1021)"
So how to solve this problem?
Note that I am a complete novice in programming, so please try to explain everything clearly.
Thanks in advance for your answers.
Last edited by Core Crash; October 11th, 2014 at 11:47 AM.
-
October 12th, 2014, 09:54 AM
#2
Re: Integral constant is too large (CS1021) - How to put 1000 integers in an array?
your error
http://msdn.microsoft.com/en-us/libr...=vs.90%29.aspx
occuring because a int's max value is 10 digits
http://www.dotnetperls.com/int-maxvalue
a ulong can take about 20 digits
for a 50 digit number you will probably need something more advanced
that takes a string representation most likely as a form of input and output
you will simply have to look into that yourself google
"c# big numbers or big number class or library"
http://www.codeproject.com/Articles/...lass-Done-in-C
Last edited by willmotil; October 12th, 2014 at 09:58 AM.
-
October 12th, 2014, 10:24 AM
#3
Re: Integral constant is too large (CS1021) - How to put 1000 integers in an array?
Thanks for your answer, but I already found the answer to my question: the BigInteger Structure.
BigInteger[] name = new[]
{
BigInteger.Parse("first-integer"),
BigInteger.Parse("second-integer"),
BigInteger.Parse("third-integer"),
...
...
};
And my program works now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|