<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi,<br><br>I ran the same code on all systems:<br><br>main () {<br>&nbsp; double i, j, k;<br>&nbsp; mpq_t rat;<br>&nbsp;<br>&nbsp; printf("hi\n");<br>&nbsp; mpq_init(rat);<br>&nbsp; mpq_set_ui(rat, 4, 5);<br>&nbsp; k = mpq_get_d(rat);<br>&nbsp; printf("rat is %.17f\n", k);<br>&nbsp;<br>}<br><br>and I built from the same GMP source. <br><br>The version of gcc used for each build is different: <br><br>32 bit Linux&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gcc 3.2.3<br>MinGW 32 bit Windows&nbsp;&nbsp;&nbsp; gcc 3.4.1<br>MinGW 64 bit Windows&nbsp;&nbsp;&nbsp; gcc 4.4.0<br><br>Does the version of gcc makes a difference? The Linux version was the only one I was able to run make check on (and it passed, as far as I can tell), because the others were all cross-compiled. <br><br>Is this a known
 issue for GMP 4.2.2 on Linux? Is there anyway I can avoid it -- I would like to use the same version of GMP for all platforms if possible.<br><br>Cheers,<br><br>Kish<br><br>--- On <b>Tue, 3/17/09, Sisyphus <i>&lt;sisyphus1@optusnet.com.au&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">From: Sisyphus &lt;sisyphus1@optusnet.com.au&gt;<br>Subject: Re: mpq_get_d() rounding for different platforms?<br>To: "K Shen" &lt;kishshen@yahoo.com&gt;, gmp-discuss@gmplib.org<br>Date: Tuesday, March 17, 2009, 10:56 AM<br><br><pre>----- Original Message ----- From: "K Shen"<br>&lt;kishshen@yahoo.com&gt;<br><br>&gt; For example, for the rational 4/5,<br>&gt; <br>&gt; the MinGW version returns 0.79999999999999993, while the Linux version<br>&gt; returns 0.80000000000000004.<br><br>Make sure that the assignment of 4/5 is being carried out in the same way.<br><br>As the following little program
 demonstrates, mpq_set_str(q, "4/5",<br>10) and mpq_set_d(q, (double) 4 / 5) assigm different values:<br><br>#############################<br>#include &lt;stdio.h&gt;<br>#include &lt;gmp.h&gt;<br><br>int main(void) {<br>   mpq_t q1;<br>   mpq_t q2;<br><br>   mpq_init(q1);<br>   mpq_init(q2);<br><br>   mpq_set_str(q1, "4/5", 10);<br>   mpq_set_d(q2, (double)4 / 5);<br><br>   printf("%.17f\n", mpq_get_d(q1));<br>   printf("%.17f\n", mpq_get_d(q2));<br><br>   mpq_clear(q1);<br>   mpq_clear(q2);<br>   return 0;<br>}<br>#############################<br><br>For me (both Linux and MinGW) that outputs:<br><br>0.79999999999999993<br>0.80000000000000004<br><br>Cheers,<br>Rob <br></pre></blockquote></td></tr></table><br>