Search code examples
c#delphinumbersradix

Convert a large number, from Base 256 to Base 10


I need to convert very large numbers from Base 256 (bytes) to Base 10 (decimal) in C# or Delphi. The actual goal is to represent contents of any given file as a very large decimal number and save it in a txt file, for example. We all know how to convert from one base to another, but the real challenge here is the size of the number. Any help would be appreciated.


Solution

  • I strongly suspect that if you're using .NET 4 or higher, you'll be able to use the BigInteger(byte[]) constructor - and then convert the result to a decimal string if you want to (or just use it as a number). You may need to reverse the bytes in the input array depending on the endianness of your input.