Error assigning large numbers to BigInteger

Trying to assign a large BigInteger number in C #

  BigInteger number= 27419669081321110693270343633073797; 

but it shows an error:

Integral Too Big

I thought BigInteger was as big as my RAM, so how can I move this number to BigInteger ?

+6
source share
3 answers

I think you can do it with BigInteger.Parse(String) . Without knowing much about C #, I think the right part of the job is wrong. Room is too big.

+9
source

I checked my VS and parsing. Try to analyze this method:

 BigInteger mybigint; bool checkparse=BigInteger.TryParse("27419669081321110693270343633073797",out mybigint); if(checkparse==false) //You can't parse this string else //string parsed 
0
source

The BigInteger type is an immutable type that represents an arbitrarily large integer; in theory, it has no upper or lower bounds.

Like Burkhard and Hank , you should use BigInteger.Parse() for this.

 BigInteger number= BigInteger.Parse("27419669081321110693270343633073797"); 

Also do not forget;

If you use the Parse() method to round the string representation of a BigInteger that was output by the ToString method, you must use the BigInteger.ToString(String) method with the format “R” specifier to create the string representation of the BigInteger value. Otherwise, the BigInteger string representation only stores the 50 most significant digits of the original value, and data may be lost when using the Parse method to restore the BigInteger value.

0
source

All Articles