Click here to Skip to main content
16,016,140 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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[^]
C#
// add a reference to System.Numerics.dll, then add this line at the top of your code file:
using System.Numerics;

C#
// 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.
 
Share this answer
 
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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900