title: Why is mpfr_printf different than printf for hex float (%a conversion specifier)?
body: <p>I'm comparing values from regular floating point arithmetic and using a high-precision MPFR number as a baseline. When printing, I'm confused why the following code is output different.</p>
  <p>The <a href="https://www.mpfr.org/mpfr-current/mpfr.html" rel="nofollow noreferrer">MPFR documentation</a> says the output specifiers are</p>
  <blockquote>
  <p>‘a’ ‘A’   hex float, C99 style&quot;</p>
  </blockquote>
  <p>So I would assume it prints the same as <code>printf</code>. However, this is not the case:</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;boost/multiprecision/mpfr.hpp&gt;
  
  #include &lt;mpfr.h&gt;
  
  using namespace boost::multiprecision;
  
  int main (int argc, char* argv[])
  {
      double               a = 254.5;
      mpfr_float_1000 mpfr_a = 254.5;
  
      mpfr_t t;
      mpfr_init2(t, 3324); // 1000 decimal precision
      mpfr_set_d(t, a, MPFR_RNDN);
  
      printf(&quot;double:\t%a\n&quot;, a);
      mpfr_printf(&quot;mpfr_t:\t%RNa\n&quot;, t);
      mpfr_printf(&quot;boost:\t%RNa\n&quot;, mpfr_a);
  }
  </code></pre>
  <p>Gives output:</p>
  <pre><code>double: 0x1.fdp+7
  mpfr_t: 0xf.e8p+4
  boost:  0xf.e8p+4
  </code></pre>
  <p>It's not a <em>huge</em> deal because <code>sscanf</code> parses both of them as the same value, but I couldn't locate any documentation explaining why they are different.</p>
  <p>Which one is canonical?</p>