title: How can I base-convert a large/high-precision floating-point number in PHP?
body: <p>As generic of a question as this seems, I'm having a really hard time 
  learning specifically about how to base-convert large high-precision float values in PHP using BCMath.</p>
  
  <p>I'm trying to base-convert something like</p>
  
  <pre><code>1234.5678900000
  </code></pre>
  
  <p>to</p>
  
  <pre><code>4D2.91613D31B
  </code></pre>
  
  <p>How can I do this?</p>
  
  <p>I just want base-10 &rarr; base-16, but a conversion for arbitrary-base floats would probably make the most useful answer for others as well.</p>
  
  <hr>
  
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/14539727/how-to-convert-a-huge-integer-to-hex-in-php">How to convert a huge integer to hex in php?</a> involves BC, but only for integers.</p></li>
  <li><p><a href="https://www.exploringbinary.com/base-conversion-in-php-using-bcmath/" rel="nofollow noreferrer">https://www.exploringbinary.com/base-conversion-in-php-using-bcmath/</a> explores floats, but only in the context of decimal&lt;->binary. (It says extending the code for other bases is easy, and it probably is (using the code in the previous point), but I have no idea how to reason through the correctness of the result I'd reach.)</p></li>
  <li><p><a href="https://stackoverflow.com/questions/24945193/fast-arbitrary-precision-logarithms-with-bcmath">Fast arbitrary-precision logarithms with bcmath</a> is also float-based, but in the context of reimplementing high-precision <code>log()</code>. (There is a mention of converting bases in there, though, along with notes about how BC dumbly uses PHP's own pow() and loses precision.)</p></li>
  </ul>
  
  <p>The other results I've found are just talking about PHP's own float coercion, and don't relate to BC at all.</p>