question

hex-5842 avatar image
0 Votes"
hex-5842 asked hex-5842 commented

huge digits

How to make variable with this huge number with more than 620 digits in Csharp
p = 62565723754058110134184001269265026995419782768569177086204348747687732348848236769229781932708360465701357972344794565740615466515350423240090663020164879389985960193699399021364476070220725008450692501480668763322130258028788020093565050589724307750757980284019043386143246778466757018917406796414009849419506348774472169291285638213327375088919193217225759978659412101547650960434445699162046310136838178962085668568787752550883666134594662568820237321652729335696495208126896696594655696472740672048375181433229185450187517242248770941384487990146267643257056551996515645627561800669155515249895921530521876406192277

I want calculate this number with pow that why I need make variable with huge number to calculte it
if there is any way to do it reply here thx

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

hex-5842 avatar image
0 Votes"
hex-5842 answered hex-5842 commented

using System.Numerics;

BigInteger number = BigInteger.Parse("23766...........08993");
Console.WriteLine(Math.Pow(number,14));

show me this Error :
cannot convert from 'System.Numerics.BigInteger' to 'double'

IDE gave me some hint i applayed
Code :

using System.Numerics;

BigInteger number = BigInteger.Parse("23766...........08993");
Console.WriteLine(Math.Pow((double)number,14));
OutPut :

106220-image.png



image.png (8.9 KiB)
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Then enter this:

 BigInteger number = BigInteger.Parse( "62565723754058110134184001269265026995419782768569177086204348747687732348848236769229781932708360465701357972344794565740615466515350423240090663020164879389985960193699399021364476070220725008450692501480668763322130258028788020093565050589724307750757980284019043386143246778466757018917406796414009849419506348774472169291285638213327375088919193217225759978659412101547650960434445699162046310136838178962085668568787752550883666134594662568820237321652729335696495208126896696594655696472740672048375181433229185450187517242248770941384487990146267643257056551996515645627561800669155515249895921530521876406192277" );
    
 BigInteger result = BigInteger.Pow( number, 14 );
    
 Console.WriteLine( result );

0 Votes 0 ·

Same Error :
106272-image.png


0 Votes 0 ·
image.png (25.3 KiB)

Try this code:

 BigInteger number = BigInteger.Parse( "62565723754058110134184001269265026995419782768569177086204348747687732348848236769229781932708360465701357972344794565740615466515350423240090663020164879389985960193699399021364476070220725008450692501480668763322130258028788020093565050589724307750757980284019043386143246778466757018917406796414009849419506348774472169291285638213327375088919193217225759978659412101547650960434445699162046310136838178962085668568787752550883666134594662568820237321652729335696495208126896696594655696472740672048375181433229185450187517242248770941384487990146267643257056551996515645627561800669155515249895921530521876406192277" );
        
  BigInteger result = BigInteger.Pow( number, 14 );
        
  Console.WriteLine( result );


0 Votes 0 ·
Show more comments
Viorel-1 avatar image
0 Votes"
Viorel-1 answered

Try the BigInteger type:

 using System.Numerics;
 . . .
 BigInteger p = BigInteger.Parse( "62565723754058110. . . . .6192277" );

Check the documentation for available operations.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.