I need to save power 1024 of 2 in a variable in c# what should i do? i tried this :
label1.Text = "0";
decimal res = 0;
res += System.Convert.ToDecimal(Math.Pow(2, 1024));
label1.Text = System.Convert.ToString(res);
I need to save power 1024 of 2 in a variable in c# what should i do? i tried this :
label1.Text = "0";
decimal res = 0;
res += System.Convert.ToDecimal(Math.Pow(2, 1024));
label1.Text = System.Convert.ToString(res);
You can try to use a BigInteger
var exponentiated = BigInteger.Pow(2, 1024);
var newText = exponentiated.ToString();
Also, if you are using an environment where the .Net BigInteger
class is not available (a project targeting .Net version 2 for example), you can use an external implementation like any of these: