I&#39;m trying to write a wrapper for GNU MP for the upcoming version of Python, but I&#39;m stuck at figuring out how to get the component parts of an mpf_t.<br><br>The current code I have works for most things, but values such as 
0.01 don&#39;t seem to exist at all!<br><br>Small example, which I&#39;ve been using to try and figure things out:<br><br><blockquote>#include &lt;stdio.h&gt;<br>#include &lt;string.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;
gmp.h&gt;<br><br>#define MPF_DEFAULT_PREC 128<br>#define MPF_DEFAULT_BASE 10<br>#define MPF_DEFAULT_SIGFIGS (size_t) 0<br><br>int main(int argc, char *argv[]) {<br>    mpf_t x;<br>    size_t sigfigs              = MPF_DEFAULT_SIGFIGS;
<br>    unsigned long int base      = MPF_DEFAULT_BASE;<br>    unsigned long int whole     = 0;<br>    unsigned long int decimal   = 0;<br>    mp_exp_t exponent;<br>    char *value                 = NULL;<br>    char *s_whole               = NULL;
<br><br>    mpf_set_default_prec(MPF_DEFAULT_PREC);<br>    mpf_init(x);<br>    mpf_set_d(x, (double) 0.01);<br><br>    value = mpf_get_str(NULL, &amp;exponent, base, sigfigs, x);<br><br>    if (strncmp(value, (char *) &quot;&quot;, 1) &gt; 0) {
<br>        if (exponent &gt; 0) {<br>            s_whole = malloc(exponent);<br>            strncpy(s_whole, value, exponent);<br>            printf(&quot;%s&quot;, s_whole);<br>        }<br><br>        value += exponent;
<br>        if (strlen(value) &gt; 0) printf(&quot;.%s\n&quot;, value);<br>    }<br><br>    mpf_clear(x);<br><br>    return 0;<br>}<br></blockquote>For the wrapper, I&#39;d ideally like to return the base, the whole component, and the decimal component. mpf_get_str seems to be the only way to do this, but I&#39;m having very little luck. mpf_get_d_2exp doesn&#39;t seem like it will help particularly, since one of the reasons for wrapping GNU MP in the first place was to avoid a loss of precision. If I multiplied things out to get the components I want, there would be a loss of precision, as well as speed.
<br><br>Help?<br><br>Thank you for your time in advance.<br><br>Rob<br><br>