</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 and initialize a new rational x.</span>
mpq_t x = <spanclass="highlight-keyword">new</span> mpq_t();
gmp_lib.mpq_init(x);
<spanclass="highlight-comment">// Assert that the value of x is 0.</span>
char_ptr s = gmp_lib.mpq_get_str(char_ptr.Zero, <spanclass="highlight-number">10</span>, x);
<spanclass="highlight-comment">// Release unmanaged memory allocated for x and its string value.</span>
gmp_lib.mpq_clear(x);
gmp_lib.free(s);</pre></div><divid="ID0EDAABA_code_Div2"class="codeSnippetContainerCode"style="display: none"><prexml:space="preserve"><spanclass="highlight-comment">' Create and initialize a new rational x.</span>
<spanclass="highlight-keyword">Dim</span> x <spanclass="highlight-keyword">As</span><spanclass="highlight-keyword">New</span> mpq_t()
gmp_lib.mpq_init(x)
<spanclass="highlight-comment">' Assert that the value of x is 0.</span>
<spanclass="highlight-keyword">Dim</span> s <spanclass="highlight-keyword">As</span> char_ptr = gmp_lib.mpq_get_str(char_ptr.Zero, <spanclass="highlight-number">10</span>, x)
gmp_lib.free(s)</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="19d53697-65f1-2df5-62f3-988182af0c88.htm">mpq_canonicalize</a></div><divclass="seeAlsoStyle"><ahref="8ab8ea40-9723-f0c8-18f4-9558c73397b9.htm">mpq_inits</a></div><divclass="seeAlsoStyle"><ahref="b69da354-160b-602a-4cc4-faf7ca423186.htm">mpq_clear</a></div><divclass="seeAlsoStyle"><ahref="cc2693e9-1cc5-3098-f2f7-bb05c8017f62.htm">mpq_clears</a></div><divclass="seeAlsoStyle"><ahref="9eac8ea9-0821-09b2-8091-e6638c562c7f.htm">mpq_set</a></div><divclass="seeAlsoStyle"><ahref="84d256a1-cd11-3bf9-3e8c-8a7e1980315d.htm">mpq_set_z</a></div><divclass="seeAlsoStyle"><ahref="915a7958-6821-bb64-468f-b0b48b351878.htm">mpq_set_ui</a></div><divclass="seeAlsoStyle"><ahref="ba898f37-20d0-a5cd-eff1-0663f18220dd.htm">mpq_set_si</a></div><divclass="seeAlsoStyle"><ahref="e98ec3cf-b539-8024-c401-ecd24bd43662.htm">mpq_set_str</a></div><divclass="seeAlsoStyle"><ahref="11e36fbc-ffc4-46df-50b7-2b07684c1755.htm">mpq_swap</a></div><divclass="seeAlsoStyle"><ahref="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm"><ahref="/Math.Gmp.Native/html/3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm#Initializing_Rationals">Initializing Rationals</a></a></div><divclass="seeAlsoStyle"><ahref="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm"><ahref="https://gmplib.org/manual/Initializing-Rationals.html#Initializing-Rationals">GNU MP - Initializing Rationals</a></a></div></div></div></div><divid="pageFooter"class="pageFooter"></div></body></html>