Wednesday, December 19, 2018

Convert Integer (stored as String) to Hexadecimal, where Integer would be larger than Int64

Hi,

I'm helping a colleague throw together a webpage (.aspx, using C#) that will take a number as an input from a form and convert it to base-16 (hex).

Problems are:

a) The number will always be 32 digits, so I can't convert it to an integer first and then do myInt.ToString("X");

b) The server it will run on doesn't have access to System.Numerics for BigInteger, otherwise that would be easy :)

Given a string containing a 32-digit unsigned integer, how can I convert it to base-16?

E.g. 12345678912345678912345678912345 -> 462d53c9baf47

All the solutions I can find either rely on the built-in ToString functions or BigInteger. Is there something else I'm missing?

Convert Integer (stored as String) to Hexadecimal, where Integer would be larger than Int64 Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team