</pre></div></div></div><scripttype="text/javascript">AddLanguageTabSet("ID0EDCA");</script><h4class="subHeading">Parameters</h4><dl><dt><spanclass="parameter">state</span></dt><dd>Type:<ahref="f7e5846d-548d-3bf3-74ac-219fde42a041.htm">Math.Gmp.Native<spanid="LSTA8E57A46_1"></span><scripttype="text/javascript">AddLanguageSpecificTextSet("LSTA8E57A46_1?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>gmp_randstate_t</a><br/>The state to seed.</dd><dt><spanclass="parameter">seed</span></dt><dd>Type:<ahref="http://msdn2.microsoft.com/en-us/library/ctys3981"target="_blank">System<spanid="LSTA8E57A46_2"></span><scripttype="text/javascript">AddLanguageSpecificTextSet("LSTA8E57A46_2?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>UInt32</a><br/>The seed.</dd></dl></div><divclass="collapsibleAreaRegion"><spanclass="collapsibleRegionTitle"onclick="SectionExpandCollapse('ID2RB')"onkeypress="SectionExpandCollapse_CheckKey('ID2RB', event)"tabindex="0"><imgid="ID2RBToggle"class="collapseToggle"src="../icons/SectionExpanded.png"/>Remarks</span></div><divid="ID2RBSection"class="collapsibleSection"><p>
The size of a seed determines how many different sequences of random numbers that it’s possible to
generate. The “quality” of the seed is the randomness of a given seed compared to the previous seed
used, and this affects the randomness of separate number sequences. The method for choosing a seed
is critical if the generated numbers are to be used for important applications, such as generating
cryptographic keys.
</p><p>
Traditionally the system time has been used to seed, but care needs to be taken with this. If an
application seeds often and the resolution of the system clock is low, then the same sequence of
numbers might be repeated. Also, the system time is quite easy to guess, so if unpredictability is
required then it should definitely not be the only source for the seed value. On some systems
there’s a special device /dev/random which provides random data better suited for use as a seed.
</p></div><divclass="collapsibleAreaRegion"><spanclass="collapsibleRegionTitle"onclick="SectionExpandCollapse('ID3RB')"onkeypress="SectionExpandCollapse_CheckKey('ID3RB', event)"tabindex="0"><imgid="ID3RBToggle"class="collapseToggle"src="../icons/SectionExpanded.png"/>Examples</span></div><divid="ID3RBSection"class="collapsibleSection"><divclass="codeSnippetContainer"><divclass="codeSnippetContainerTabs"><divid="ID0EDAABA_tab1"class="codeSnippetContainerTab"><ahref="#"onclick="javascript:ChangeTab('ID0EDAABA','cs','1','4');return false;">C#</a></div><divid="ID0EDAABA_tab2"class="codeSnippetContainerTab"><ahref="#"onclick="javascript:ChangeTab('ID0EDAABA','vb','2','4');return false;">VB</a></div><divid="ID0EDAABA_tab3"class="codeSnippetContainerTabPhantom"><ahref="#"onclick="javascript:ChangeTab('ID0EDAABA','cpp','3','4');return false;">C++</a></div><divid="ID0EDAABA_tab4"class="codeSnippetContainerTabPhantom"><ahref="#"onclick="javascript:ChangeTab('ID0EDAABA','fs','4','4');return false;">F#</a></div></div><divclass="codeSnippetContainerCodeContainer"><divclass="codeSnippetToolBar"><divclass="codeSnippetToolBarText"><aid="ID0EDAABA_copyCode"href="#"class="copyCodeSnippet"onclick="javascript:CopyToClipboard('ID0EDAABA');return false;"title="Copy">Copy</a></div></div><divid="ID0EDAABA_code_Div1"class="codeSnippetContainerCode"style="display: block"><prexml:space="preserve"><spanclass="highlight-comment">// Create new random number generator state, and initialize state with the Mersenne Twister algorithm.</span>
gmp_randstate_t state = <spanclass="highlight-keyword">new</span> gmp_randstate_t();
gmp_lib.gmp_randinit_mt(state);
<spanclass="highlight-comment">// Seed random number generator.</span>
<spanclass="highlight-comment">// Free all memory occupied by state.</span>
gmp_lib.gmp_randclear(state);</pre></div><divid="ID0EDAABA_code_Div2"class="codeSnippetContainerCode"style="display: none"><prexml:space="preserve"><spanclass="highlight-comment">' Create new random number generator state, and initialize state with the Mersenne Twister algorithm.</span>
<spanclass="highlight-keyword">Dim</span> state <spanclass="highlight-keyword">As</span><spanclass="highlight-keyword">New</span> gmp_randstate_t()
gmp_lib.gmp_randinit_mt(state)
<spanclass="highlight-comment">' Seed random number generator.</span>
<spanclass="highlight-comment">' Free all memory occupied by state.</span>
gmp_lib.gmp_randclear(state) ///</pre></div><divid="ID0EDAABA_code_Div3"class="codeSnippetContainerCode"style="display: none"><p>No code example is currently available or this language may not be supported.</p></div><divid="ID0EDAABA_code_Div4"class="codeSnippetContainerCode"style="display: none"><p>No code example is currently available or this language may not be supported.</p></div></div></div><scripttype="text/javascript">AddLanguageTabSet("ID0EDAABA");</script></div><divclass="collapsibleAreaRegion"id="seeAlsoSection"><spanclass="collapsibleRegionTitle"onclick="SectionExpandCollapse('ID4RB')"onkeypress="SectionExpandCollapse_CheckKey('ID4RB', event)"tabindex="0"><imgid="ID4RBToggle"class="collapseToggle"src="../icons/SectionExpanded.png"/>See Also</span></div><divid="ID4RBSection"class="collapsibleSection"><h4class="subHeading">Reference</h4><divclass="seeAlsoStyle"><ahref="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm">gmp_lib Class</a></div><divclass="seeAlsoStyle"><ahref="d9c51b9f-0c54-770b-28ea-6eebd8fef368.htm">Math.Gmp.Native Namespace</a></div><divclass="seeAlsoStyle"><ahref="b31d5778-362b-b75f-40cc-4c8280ca889c.htm">gmp_lib<spanid="LSTA8E57A46_3"></span><scripttype="text/javascript">AddLanguageSpecificTextSet("LSTA8E57A46_3?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>gmp_randseed(gmp_randstate_t, mpz_t)</a></div><divclass="seeAlsoStyle"><ahref="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm"><ahref="https://gmplib.org/manual/Random-State-Seeding.html#Random-State-Seeding">GNU MP - Random State Seeding</a></a></div></div></div></div><divid="pageFooter"class="pageFooter"></div></body></html>