title: How to use printf with mpfr and mpreal
body: <p>What is the correct syntax for using <code>printf</code> and its cousins <code>sprintf</code> and <code>fprintf</code> to display the value of <code>mpreal</code>-type variables? I have tried the naive casting to double:</p>
  
  <pre><code>printf ("... %g ...", (double) var);
  </code></pre>
  
  <p>only to receive this error message from g++:</p>
  
  <pre><code>error: invalid cast from type ‘mpfr::mpreal’ to type ‘double’
  </code></pre>
  
  <p>I had no problem using <code>double</code>-type variables elsewhere on the program.</p>
  
  <p>I heard about the type <code>mpreal</code> as part of this <a href="http://www.holoborodko.com/pavel/mpfr/" rel="nofollow">library</a> intended to enable the use of the usual binary operators to perform arbitrary precision arithmetic operations.</p>