<html><head><metahttp-equiv="X-UA-Compatible"content="IE=edge"/><linkrel="shortcut icon"href="../icons/favicon.ico"/><linkrel="stylesheet"type="text/css"href="../styles/branding.css"/><linkrel="stylesheet"type="text/css"href="../styles/branding-en-US.css"/><scripttype="text/javascript"src="../scripts/branding.js"></script><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"/><title>gmp_lib.gmp_randinit_lc_2exp_size Method </title><metaname="Language"content="en-us"/><metaname="System.Keywords"content="gmp_randinit_lc_2exp_size method"/><metaname="System.Keywords"content="gmp_lib.gmp_randinit_lc_2exp_size method"/><metaname="Microsoft.Help.F1"content="Math.Gmp.Native.gmp_lib.gmp_randinit_lc_2exp_size"/><metaname="Microsoft.Help.Id"content="M:Math.Gmp.Native.gmp_lib.gmp_randinit_lc_2exp_size(Math.Gmp.Native.gmp_randstate_t,Math.Gmp.Native.mp_bitcnt_t)"/><metaname="Description"content="Initialize for a linear congruential algorithm as per gmp_randinit_lc_2exp."/><metaname="Microsoft.Help.ContentType"content="Reference"/><metaname="BrandingAware"content="true"/><metaname="container"content="Math.Gmp.Native"/><metaname="file"content="f209112e-311a-88cd-becf-33bc3787f91d"/><metaname="guid"content="f209112e-311a-88cd-becf-33bc3787f91d"/><linktype="text/css"rel="stylesheet"href="../styles/highlight.css"/><scripttype="text/javascript"src="../scripts/highlight.js"></script><linkrel="stylesheet"type="text/css"href="../styles/branding-Website.css"/><scripttype="text/javascript"src="../scripts/jquery-1.11.0.min.js"></script><scripttype="text/javascript"src="../scripts/branding-Website.js"></script><scripttype="text/javascript"src="../scripts/clipboard.min.js"></script></head><bodyonload="OnLoad('cs')"><inputtype="hidden"id="userDataCache"class="userDataStyle"/><divclass="pageHeader"id="PageHeader">GMP Native Interface for .NET<formid="SearchForm"method="get"action="#"onsubmit="javascript:TransferToSearchPage(); return false;"><inputid="SearchTextBox"type="text"maxlength="200"/><buttonid="SearchButton"type="submit"></button></form></div><divclass="pageBody"><divclass="leftNav"id="leftNav"><divid="tocNav"><divclass="toclevel0"data-toclevel="0"><aclass="tocCollapsed"onclick="javascript: Toggle(this);"href="#!"/><adata-tochassubtree="true"href="846f5c8a-6cba-433e-9f18-cde2ff5695cd.htm"title="GMP Native Interface for .NET"tocid="roottoc">GMP Native Interface for .NET</a></div><divclass="toclevel0"data-toclevel="0"><aclass="tocCollapsed"onclick="javascript: Toggle(this);"href="#!"/><adata-tochassubtree="true"href="d9c51b9f-0c54-770b-28ea-6eebd8fef368.htm"title="Math.Gmp.Native"tocid="d9c51b9f-0c54-770b-28ea-6eebd8fef368">Math.Gmp.Native</a></div><divclass="toclevel0"data-toclevel="0"><aclass="tocCollapsed"onclick="javascript: Toggle(this);"href="#!"/><adata-tochassubtree="true"href="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm"title="gmp_lib Class"tocid="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f">gmp_lib Class</a></div><divclass="toclevel1"data-toclevel="1"data-childrenloaded="true"><aclass="tocExpanded"onclick="javascript: Toggle(this);"href="#!"/><adata-tochassubtree="true"href="0fa7cbf3-e8f4-6b14-d829-8aa663e77c74.htm"title="gmp_lib Methods"tocid="0fa7cbf3-e8f4-6b14-d829-8aa663e77c74">gmp_lib Methods</a></div><divclass="toclevel2"data-toclevel="2"><adata-tochassubtree="false"href="c9cb6a67-59b8-5c03-f31d-f252441c53f6.htm"title="_mpz_realloc Method "tocid="c9cb6a67-59b8-5c03-f31d-f252441c53f6">_mpz_realloc Method </a></div><divclass="toclevel2"data-toclevel="2"><adata-tochassubtree="false"href="2c68671c-cd5c-e2ec-52a2-65b0ca31c3d1.htm"title="allocate Method "tocid="2c68671c-cd5c-e2ec-52a2-65b0ca31c3d1">allocate Method </a></div><divclass="toclevel2"data-toclevel="2"><aclass="tocCollapsed"onclick="javascript: Toggle(this);"href="#!"/><adata-tochassubtree="true"href="92160da3-b1af-e005-cb05-e3fb4dd524d8.htm"title="free Method "tocid="92160da3-b1af-e005-cb05-e3fb4dd524d8">free Metho
Initialize <spanclass="parameter">state</span> for a linear congruential algorithm as per <ahref="21fdbc76-a0de-1f3a-195f-a5ae0cb3d1da.htm">gmp_randinit_lc_2exp</a>.
</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="LST4A14CC76_1"></span><scripttype="text/javascript">AddLanguageSpecificTextSet("LST4A14CC76_1?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>gmp_randstate_t</a><br/>The state to initialize.</dd><dt><spanclass="parameter">size</span></dt><dd>Type:<ahref="1b2b1d64-20c1-7a64-0278-d9ff58ee9cc3.htm">Math.Gmp.Native<spanid="LST4A14CC76_2"></span><scripttype="text/javascript">AddLanguageSpecificTextSet("LST4A14CC76_2?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>mp_bitcnt_t</a><br/></dd></dl><h4class="subHeading">Return Value</h4>Type:<ahref="http://msdn2.microsoft.com/en-us/library/td2s409d"target="_blank">Int32</a><br/>If successful the return value is non-zero. If <spanclass="parameter">size</span> is bigger than the table data provides then the return value is zero.</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>
a, c and m2exp are selected from a table, chosen so that <spanclass="parameter">size</span>
bits (or more) of each X will be used, i.e. m2exp / 2 ≥ <spanclass="parameter">size</span>.
</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.</span>
gmp_randstate_t state = <spanclass="highlight-keyword">new</span> gmp_randstate_t();
<spanclass="highlight-comment">// Initialize state with a linear congruential random number generator algorithm.</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.</span>
<spanclass="highlight-keyword">Dim</span> state <spanclass="highlight-keyword">As</span><spanclass="highlight-keyword">New</span> gmp_randstate_t()
<spanclass="highlight-comment">' Initialize state with a linear congruential random number generator algorithm.</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="7ef82a61-e43a-78c7-a28f-8f2d0a5f59b1.htm">gmp_randclear</a></div><divclass="seeAlsoStyle"><ahref="89fff39e-9dc4-4d23-9460-301ae7df92d1.htm">gmp_randinit_default</a></div><divclass="seeAlsoStyle"><ahref="21fdbc76-a0de-1f3a-195f-a5ae0cb3d1da.htm">gmp_randinit_lc_2exp</a></div><divclass="seeAlsoStyle"><ahref="b3ed0ded-086a-41f1-6051-d08afa338da8.htm">gmp_randinit_mt</a></div><divclass="seeAlsoStyle"><ahref="494fa261-4044-f216-7041-a55d95a26f5b.htm">gmp_randinit_set</a></div><divclass="seeAlsoStyle"><ahref="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm"><ahref="/html/3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm#Random_State_Initialization">Random State Initialization</a></a></div><divclass="seeAlsoStyle"><ahref="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm"><ahref="https://gmplib.org/manual/Random-State-Initialization.html#Random-State-Initialization">GNU MP - Random State Initialization</a></a></div></div></div></div><divid="pageFooter"class="pageFooter"></div></body></html>