Click here to Skip to main content
14,580,573 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have A 25 digit decimal values like 1011406131533376933715533 and I want to convert it into Hexadecimal vice verse.
please help me..
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Hi,

For very large numbers, use a BigInteger (supported in .NET 4.5, 4 and .NET 4 Client Profile):
http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx[^]
// add a reference to System.Numerics.dll, then add this line at the top of your code file:
using System.Numerics;

// decimal to hex:
BigInteger dec = BigInteger.Parse("1011406131533376933715533");
string hex = dec.ToString("X");
Console.WriteLine(hex); // output: 0D62C6FAE52427AB5DE4D

// hex to decimal:
string hex2 = "0D62C6FAE52427AB5DE4D";
BigInteger dec2 = BigInteger.Parse(hex2, System.Globalization.NumberStyles.HexNumber);
Console.WriteLine(dec2); // output: 1011406131533376933715533

Hope this helps.
   
Comments
CPallini 21-Jun-13 7:35am
   
5.
Thomas Daniels 21-Jun-13 7:36am
   
Thank you!
Member 10273293 8-Jul-15 4:26am
   
is there any biggest data type conpair the bigintger
because i have a hexa value like this 45203795024b66627559a4754ff677f54cbc360bc37fc91e00ca66e1b843878fe
Thomas Daniels 8-Jul-15 4:32am
   
What do you mean exactly? Why doesn't BigInteger work for that hex value?
Member 10273293 8-Jul-15 5:20am
   
i need some more bigger data type because my hexa value is 64 char or more here is the example
5b16bb86d2db626a8dc1961b32796beb208a4ad4360f2efd59ee74766d30b25340
Thomas Daniels 8-Jul-15 5:20am
   
BigInteger is the biggest type you can have. It does not have problems with huge values unless your computer runs out of memory.
Member 10273293 8-Jul-15 5:23am
   
ok i try for this
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100