title: Fastest algorithm to convert hexadecimal numbers into decimal form without using a fixed length variable to store the result
body: <p>I want to write a program to convert hexadecimal numbers into their decimal forms without using a variable of fixed length to store the result because that would restrict the range of inputs that my program can work with.  </p>
  
  <p>Let's say I were to use a variable of type <code>long long int</code> to calculate, store and print the result. Doing so would limit the range of hexadecimal numbers that my program can handle to between <code>8000000000000001</code> and <code>7FFFFFFFFFFFFFFF</code>. Anything outside this range would cause the variable to overflow.  </p>
  
  <p>I did write a program that calculates and stores the decimal result in a dynamically allocated string by performing carry and borrow operations but it runs much slower, even for numbers that are as big as <code>7FFFFFFFF</code>!  </p>
  
  <p>Then I stumbled onto <a href="https://www.rapidtables.com/convert/number/hex-to-decimal.html" rel="nofollow noreferrer">this site</a> which could take numbers that are way outside the range of a 64 bit variable. I tried their converter with numbers much larger than <code>16^65 - 1</code> and still couldn't get it to overflow. It just kept on going and printing the result.  </p>
  
  <p>I figured that they must be using a much better algorithm for hex to decimal conversion, one that isn't limited to 64 bit values. </p>
  
  <p>So far, Google's search results have only led me to algorithms that use some fixed-length variable for storing the result.</p>
  
  <p>That's why I am here. I wanna know if such an algorithm exists and if it does, what is it?</p>