<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> double i, j, k;<br> mpq_t rat;<br> <br> printf("hi\n");<br> mpq_init(rat);<br> mpq_set_ui(rat, 4, 5);<br> k = mpq_get_d(rat);<br> printf("rat is %.17f\n", k);<br> <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 gcc 3.2.3<br>MinGW 32 bit Windows gcc 3.4.1<br>MinGW 64 bit Windows 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><sisyphus1@optusnet.com.au></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">From: Sisyphus <sisyphus1@optusnet.com.au><br>Subject: Re: mpq_get_d() rounding for different platforms?<br>To: "K Shen" <kishshen@yahoo.com>, gmp-discuss@gmplib.org<br>Date: Tuesday, March 17, 2009, 10:56 AM<br><br><pre>----- Original Message ----- From: "K Shen"<br><kishshen@yahoo.com><br><br>> For example, for the rational 4/5,<br>> <br>> the MinGW version returns 0.79999999999999993, while the Linux version<br>> 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 <stdio.h><br>#include <gmp.h><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>