<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.mpn_gcdext Method (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t)</title><metaname="Language"content="en-us"/><metaname="Microsoft.Help.Id"content="M:Math.Gmp.Native.gmp_lib.mpn_gcdext(Math.Gmp.Native.mp_ptr,Math.Gmp.Native.mp_ptr,Math.Gmp.Native.mp_size_t@,Math.Gmp.Native.mp_ptr,Math.Gmp.Native.mp_size_t,Math.Gmp.Native.mp_ptr,Math.Gmp.Native.mp_size_t)"/><metaname="Description"content="Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT."/><metaname="Microsoft.Help.ContentType"content="Reference"/><metaname="BrandingAware"content="true"/><metaname="container"content="Math.Gmp.Native"/><metaname="file"content="c7536923-2242-a346-3211-02806aebd69f"/><metaname="guid"content="c7536923-2242-a346-3211-02806aebd69f"/><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="toclevel0"data-toclevel="0"><aclass="tocCollapsed"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="toclevel1"data-toclevel="1"data-childrenloaded="true"><aclass="tocExpanded"onclick="javascript: Toggle(this);"href="#!"/><adata-tochassubtree="true"href="1d98a5d2-dff5-3fd2-c322-13c56beabb21.htm"title="mpn_gcdext Method "tocid="1d98a5d2-dff5-3fd2-c322-13c56beabb21">mpn_gcdext Method </a></div><divclass="toclevel2 current"data-toclevel="2"><adata-tochassubtree="false"href="c7536923-2242-a346-3211-02806aebd69f.htm"title="mpn_gcdext Method (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t)"tocid="c7536923-2242-a346-3211-02806aebd69f">mpn_gcdext Method (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_ptr, mp_size_t)</a></div><divclass="toclevel2"data-toclevel="2"><adata-tochassubtree="false"href="746d102a-5f3e-6142-b02a-63f3cac385ab.htm"title="mpn_gcdextMetho
Compute the greatest common divisor G of U and V. Compute a cofactor S such that G = US + VT.
</pre></div></div></div><scripttype="text/javascript">AddLanguageTabSet("ID0EDCA");</script><h4class="subHeading">Parameters</h4><dl><dt><spanclass="parameter">gp</span></dt><dd>Type:<ahref="4609ac5e-5cf9-cd20-2fa9-8040101c165c.htm">Math.Gmp.Native<spanid="LST405A0C2B_2"></span><scripttype="text/javascript">AddLanguageSpecificTextSet("LST405A0C2B_2?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>mp_ptr</a><br/>The fisrt result operand.</dd><dt><spanclass="parameter">sp</span></dt><dd>Type:<ahref="4609ac5e-5cf9-cd20-2fa9-8040101c165c.htm">Math.Gmp.Native<spanid="LST405A0C2B_3"></span><scripttype="text/javascript">AddLanguageSpecificTextSet("LST405A0C2B_3?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>mp_ptr</a><br/>The second result operand.</dd><dt><spanclass="parameter">sn</span></dt><dd>Type:<ahref="4b58a584-7a0e-b600-18fa-ebd493861eb3.htm">Math.Gmp.Native<spanid="LST405A0C2B_4"></span><scripttype="text/javascript">AddLanguageSpecificTextSet("LST405A0C2B_4?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>mp_size_t</a><spanid="LST405A0C2B_5"></span><scripttype="text/javascript">AddLanguageSpecificTextSet("LST405A0C2B_5?cpp=%");</script><br/>Pointer to the number of limbs of <spanclass="parameter">sp</span>.</dd><dt><spanclass="parameter">up</span></dt><dd>Type:<ahref="4609ac5e-5cf9-cd20-2fa9-8040101c165c.htm">Math.Gmp.Native<spanid="LST405A0C2B_6"></span><scripttype="text/javascript">AddLanguageSpecificTextSet("LST405A0C2B_6?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>mp_ptr</a><br/>The first operand integer.</dd><dt><spanclass="parameter">un</span></dt><dd>Type:<ahref="4b58a584-7a0e-b600-18fa-ebd493861eb3.htm">Math.Gmp.Native<spanid="LST405A0C2B_7"></span><scripttype="text/javascript">AddLanguageSpecificTextSet("LST405A0C2B_7?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>mp_size_t</a><br/>The number of limbs of <spanclass="parameter">up</span>.</dd><dt><spanclass="parameter">vp</span></dt><dd>Type:<ahref="4609ac5e-5cf9-cd20-2fa9-8040101c165c.htm">Math.Gmp.Native<spanid="LST405A0C2B_8"></span><scripttype="text/javascript">AddLanguageSpecificTextSet("LST405A0C2B_8?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>mp_ptr</a><br/>The second operand integer.</dd><dt><spanclass="parameter">vn</span></dt><dd>Type:<ahref="4b58a584-7a0e-b600-18fa-ebd493861eb3.htm">Math.Gmp.Native<spanid="LST405A0C2B_9"></span><scripttype="text/javascript">AddLanguageSpecificTextSet("LST405A0C2B_9?cs=.|vb=.|cpp=::|nu=.|fs=.");</script>mp_size_t</a><br/>The number of limbs of <spanclass="parameter">vp</span>.</dd></dl><h4class="subHeading">Return Value</h4>Type:<ahref="4b58a584-7a0e-b600-18fa-ebd493861eb3.htm">mp_size_t</a><br/>The number of limbs of <spanclass="parameter">gp</span>.</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>
Let U be defined by {<spanclass="parameter">up</span>, <spanclass="parameter">un</span>}
and let V be defined by {<spanclass="parameter">vp</span>, <spanclass="parameter">vn</span>}.
</p><p>
The second cofactor T is not computed but can easily be obtained from (G - U * S) / V (the division will be exact).
It is required that <spanclass="parameter">un</span> ≥ <spanclass="parameter">vn</span>> 0,
and the most significant limb of {<spanclass="parameter">vp</span>, <spanclass="parameter">vn</span>} must be non-zero.
</p><p>
Store G at <spanclass="parameter">gp</span> and let the return value define its limb count.
Store S at <spanclass="parameter">sp</span> and let | <spanclass="parameter">sn</span>.Value | define its limb count.
S can be negative; when this happens <spanclass="parameter">sn</span>.Value will be negative.
The area at <spanclass="parameter">gp</span> should have room for <spanclass="parameter">vn</span> limbs
and the area at <spanclass="parameter">sp</span> should have room for <spanclass="parameter">vn</span> + 1 limbs.
</p><p>
Both source operands are destroyed.
</p><p>
Compatibility notes: GMP 4.3.0 and 4.3.1 defined S less strictly.
Earlier as well as later GMP releases define S as described here.
GMP releases before GMP 4.3.0 required additional space for both input and output areas.
More precisely, the areas {<spanclass="parameter">up</span>, <spanclass="parameter">un</span> + 1} and
{<spanclass="parameter">vp</span>, <spanclass="parameter">vn</span> + 1} were destroyed (i.e. the operands
plus an extra limb past the end of each), and the areas pointed to by <spanclass="parameter">gp</span>
and <spanclass="parameter">sp</span> should each have room for <spanclass="parameter">un</span> + 1 limbs.
gmp_lib.free(gp, up, vp, sp, result, cofactor)</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="1d98a5d2-dff5-3fd2-c322-13c56beabb21.htm">mpn_gcdext Overload</a></div><divclass="seeAlsoStyle"><ahref="d9c51b9f-0c54-770b-28ea-6eebd8fef368.htm">Math.Gmp.Native Namespace</a></div><divclass="seeAlsoStyle"><ahref="24ecd2d5-422f-e538-fd43-94b749652393.htm">mpn_gcd</a></div><divclass="seeAlsoStyle"><ahref="64373933-f98b-74b4-c10f-3b1a98c410bc.htm">mpn_gcd_1</a></div><divclass="seeAlsoStyle"><ahref="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm"><ahref="/html/3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm#Low_level_Functions">Low-level Functions</a></a></div><divclass="seeAlsoStyle"><ahref="3af6b34c-3242-2b75-e7c7-ab79af8a4b0f.htm"><ahref="https://gmplib.org/manual/Low_002dlevel-Functions.html#Low_002dlevel-Functions">GNU MP - Low-level Functions</a></a></div></div></div></div><divid="pageFooter"class="pageFooter"></div></body></html>