<?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[porting to QRandomGenerator]]></title><description><![CDATA[<p dir="auto">I am porting some old code under qt 5.15.2.</p>
<p dir="auto">qsrand(30);<br />
qDebug() &lt;&lt; "qrand" &lt;&lt; qrand();<br />
qDebug() &lt;&lt; "qrand" &lt;&lt; qrand();<br />
qDebug() &lt;&lt; "qrand" &lt;&lt; qrand();</p>
<p dir="auto">this code always gives me the same result. With the same result I mean the same sequence. In the new code I have written:</p>
<p dir="auto">QRandomGenerator generator;<br />
generator.seed(30);</p>
<p dir="auto">qDebug() &lt;&lt; "randomGenerator" &lt;&lt; randGenerator.bounded(RAND_MAX);<br />
qDebug() &lt;&lt; "randomGenerator" &lt;&lt; randGenerator.bounded(RAND_MAX);<br />
qDebug() &lt;&lt; "randomGenerator" &lt;&lt; randGenerator.bounded(RAND_MAX);</p>
<p dir="auto">this too has always the same result but the values ​​are different from the previous case. can i have the same result of the old qrand?</p>
]]></description><link>https://forum.qt.io/topic/127019/porting-to-qrandomgenerator</link><generator>RSS for Node</generator><lastBuildDate>Tue, 05 May 2026 18:29:42 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/127019.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 26 May 2021 14:42:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to porting to QRandomGenerator on Wed, 26 May 2021 15:55:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/massimiliano75">@<bdi>Massimiliano75</bdi></a> said in <a href="/post/661718">porting to QRandomGenerator</a>:</p>
<blockquote>
<p dir="auto">can i have the same result of the old qrand?</p>
</blockquote>
<p dir="auto">You really should understand what 'random' means...</p>
]]></description><link>https://forum.qt.io/post/661739</link><guid isPermaLink="true">https://forum.qt.io/post/661739</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Wed, 26 May 2021 15:55:54 GMT</pubDate></item><item><title><![CDATA[Reply to porting to QRandomGenerator on Wed, 26 May 2021 15:00:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/massimiliano75">@<bdi>Massimiliano75</bdi></a> said in <a href="/post/661718">porting to QRandomGenerator</a>:</p>
<blockquote>
<p dir="auto">can i have the same result of the old qrand?</p>
</blockquote>
<p dir="auto">I have <em>no evidence</em> for my answer, but I am interested in anything to do with random &amp; pseudo-random numbers.</p>
<p dir="auto">I would <em>very much doubt</em> that you can use the same seed, or even any other seed, to generate the same sequence as it used to be.  I would <em>imagine</em> these two use different pseudo-generator algorithms, and hence won't produce the same sequences as each other.  Seed or not.</p>
<p dir="auto">I guess this could be a problem when upgrading for <em>testing</em> (with existing result sets), but haven't seen a comment about this.</p>
<p dir="auto">Unless someone who knows the changed code tells you otherwise... :)</p>
]]></description><link>https://forum.qt.io/post/661723</link><guid isPermaLink="true">https://forum.qt.io/post/661723</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 26 May 2021 15:00:10 GMT</pubDate></item></channel></rss>