<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[gmp + c++: assign rationals]]></title><description><![CDATA[<p>I have initialize a rational and two integers. I want to assign to it different values:<br />
mpq_class a;<br />
int b;<br />
inc c;<br />
if (...){<br />
... calculate b,c;<br />
assign a=b/c;<br />
}<br />
else {<br />
... calculate b,c;<br />
assign a=b/c<br />
}</p>
<p>So I want to assign to a, b/c but not wenn I initialize it but at an other point of the program. How can I do that?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/273667/gmp-c-assign-rationals</link><generator>RSS for Node</generator><lastBuildDate>Fri, 28 Aug 2026 01:14:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/273667.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 10 Sep 2010 16:44:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to gmp + c++: assign rationals on Fri, 10 Sep 2010 16:44:03 GMT]]></title><description><![CDATA[<p>I have initialize a rational and two integers. I want to assign to it different values:<br />
mpq_class a;<br />
int b;<br />
inc c;<br />
if (...){<br />
... calculate b,c;<br />
assign a=b/c;<br />
}<br />
else {<br />
... calculate b,c;<br />
assign a=b/c<br />
}</p>
<p>So I want to assign to a, b/c but not wenn I initialize it but at an other point of the program. How can I do that?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1951024</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951024</guid><dc:creator><![CDATA[math student]]></dc:creator><pubDate>Fri, 10 Sep 2010 16:44:03 GMT</pubDate></item><item><title><![CDATA[Reply to gmp + c++: assign rationals on Fri, 10 Sep 2010 18:42:37 GMT]]></title><description><![CDATA[<p>you can do it by mpq_class a (b,c) also if you have already defined it by mpq_class a;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1951093</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951093</guid><dc:creator><![CDATA[math student]]></dc:creator><pubDate>Fri, 10 Sep 2010 18:42:37 GMT</pubDate></item><item><title><![CDATA[Reply to gmp + c++: assign rationals on Sat, 11 Sep 2010 06:29:01 GMT]]></title><description><![CDATA[<p>math student schrieb:</p>
<blockquote>
<p>I have initialize a rational and two integers. I want to assign to it different values:<br />
mpq_class a;<br />
int b;<br />
inc c;<br />
if (...){<br />
... calculate b,c;<br />
assign a=b/c;<br />
}<br />
else {<br />
... calculate b,c;<br />
assign a=b/c<br />
}</p>
<p>So I want to assign to a, b/c but not wenn I initialize it but at an other point of the program. How can I do that?</p>
</blockquote>
<p>if the implementor of mpq_class has defined an mpq_class::operator=(mpq_class const&amp;), you could assign a temporary object of that class to 'a' and initialize that temporary with b and c:</p>
<pre><code class="language-cpp">a = mpq_class(b, c);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1951156</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951156</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Sat, 11 Sep 2010 06:29:01 GMT</pubDate></item></channel></rss>