📄 integer_8h-source.html
字号:
<a name="l00292"></a>00292 <span class="comment"> \retval 0 if *this = a</span><a name="l00293"></a>00293 <span class="comment"> \retval 1 if *this > a</span><a name="l00294"></a>00294 <span class="comment"> */</span><a name="l00295"></a>00295 <span class="keywordtype">int</span> Compare(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>& a) <span class="keyword">const</span>;<a name="l00296"></a>00296 <span class="comment"></span><a name="l00297"></a>00297 <span class="comment"> //!</span><a name="l00298"></a>00298 <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> Plus(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &b) <span class="keyword">const</span>;<span class="comment"></span><a name="l00299"></a>00299 <span class="comment"> //!</span><a name="l00300"></a>00300 <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> Minus(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &b) <span class="keyword">const</span>;<span class="comment"></span><a name="l00301"></a>00301 <span class="comment"> //!</span><a name="l00302"></a>00302 <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> Times(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &b) <span class="keyword">const</span>;<span class="comment"></span><a name="l00303"></a>00303 <span class="comment"> //!</span><a name="l00304"></a>00304 <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> DividedBy(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &b) <span class="keyword">const</span>;<span class="comment"></span><a name="l00305"></a>00305 <span class="comment"> //!</span><a name="l00306"></a>00306 <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> Modulo(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &b) <span class="keyword">const</span>;<span class="comment"></span><a name="l00307"></a>00307 <span class="comment"> //!</span><a name="l00308"></a>00308 <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> DividedBy(word b) <span class="keyword">const</span>;<span class="comment"></span><a name="l00309"></a>00309 <span class="comment"> //!</span><a name="l00310"></a>00310 <span class="comment"></span> word Modulo(word b) <span class="keyword">const</span>;<a name="l00311"></a>00311 <span class="comment"></span><a name="l00312"></a>00312 <span class="comment"> //!</span><a name="l00313"></a><a class="code" href="class_integer.html#590c29985d3edfdb9b5dab9f6d5ad3b1">00313</a> <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> operator>>(<span class="keywordtype">size_t</span> n)<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>(*<span class="keyword">this</span>)>>=n;}<span class="comment"></span><a name="l00314"></a>00314 <span class="comment"> //!</span><a name="l00315"></a><a class="code" href="class_integer.html#af2d3f82da9d6d03b79984178170df07">00315</a> <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> operator<<(<span class="keywordtype">size_t</span> n)<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>(*<span class="keyword">this</span>)<<=n;}<span class="comment"></span><a name="l00316"></a>00316 <span class="comment"> //@}</span><a name="l00317"></a>00317 <span class="comment"></span><span class="comment"></span><a name="l00318"></a>00318 <span class="comment"> //! \name OTHER ARITHMETIC FUNCTIONS</span><a name="l00319"></a>00319 <span class="comment"></span><span class="comment"> //@{</span><a name="l00320"></a>00320 <span class="comment"></span><span class="comment"> //!</span><a name="l00321"></a>00321 <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> AbsoluteValue() <span class="keyword">const</span>;<span class="comment"></span><a name="l00322"></a>00322 <span class="comment"> //!</span><a name="l00323"></a><a class="code" href="class_integer.html#4d86bd0bc25c23b4c6a797a8eff3a41f">00323</a> <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> Doubled()<span class="keyword"> const </span>{<span class="keywordflow">return</span> Plus(*<span class="keyword">this</span>);}<span class="comment"></span><a name="l00324"></a>00324 <span class="comment"> //!</span><a name="l00325"></a><a class="code" href="class_integer.html#7b5e639045868c5ac338f4180e1c7efa">00325</a> <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> Squared()<span class="keyword"> const </span>{<span class="keywordflow">return</span> Times(*<span class="keyword">this</span>);}<span class="comment"></span><a name="l00326"></a>00326 <span class="comment"> //! extract square root, if negative return 0, else return floor of square root</span><a name="l00327"></a>00327 <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> SquareRoot() <span class="keyword">const</span>;<span class="comment"></span><a name="l00328"></a>00328 <span class="comment"> //! return whether this integer is a perfect square</span><a name="l00329"></a>00329 <span class="comment"></span> <span class="keywordtype">bool</span> IsSquare() <span class="keyword">const</span>;<a name="l00330"></a>00330 <span class="comment"></span><a name="l00331"></a>00331 <span class="comment"> //! is 1 or -1</span><a name="l00332"></a>00332 <span class="comment"></span> <span class="keywordtype">bool</span> IsUnit() <span class="keyword">const</span>;<span class="comment"></span><a name="l00333"></a>00333 <span class="comment"> //! return inverse if 1 or -1, otherwise return 0</span><a name="l00334"></a>00334 <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> MultiplicativeInverse() <span class="keyword">const</span>;<a name="l00335"></a>00335 <span class="comment"></span><a name="l00336"></a>00336 <span class="comment"> //! modular multiplication</span><a name="l00337"></a>00337 <span class="comment"></span> CRYPTOPP_DLL <span class="keyword">friend</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> CRYPTOPP_API a_times_b_mod_c(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &x, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>& y, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>& m);<span class="comment"></span><a name="l00338"></a>00338 <span class="comment"> //! modular exponentiation</span><a name="l00339"></a>00339 <span class="comment"></span> CRYPTOPP_DLL <span class="keyword">friend</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> CRYPTOPP_API a_exp_b_mod_c(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &x, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>& e, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a>& m);<a name="l00340"></a>00340 <span class="comment"></span><a name="l00341"></a>00341 <span class="comment"> //! calculate r and q such that (a == d*q + r) && (0 <= r < abs(d))</span><a name="l00342"></a>00342 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">void</span> CRYPTOPP_API Divide(<a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &r, <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &q, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &a, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &d);<span class="comment"></span><a name="l00343"></a>00343 <span class="comment"> //! use a faster division algorithm when divisor is short</span><a name="l00344"></a>00344 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">void</span> CRYPTOPP_API Divide(word &r, <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &q, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &a, word d);<a name="l00345"></a>00345 <span class="comment"></span><a name="l00346"></a>00346 <span class="comment"> //! returns same result as Divide(r, q, a, Power2(n)), but faster</span><a name="l00347"></a>00347 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">void</span> CRYPTOPP_API DivideByPowerOf2(<a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &r, <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &q, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &a, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> n);<a name="l00348"></a>00348 <span class="comment"></span><a name="l00349"></a>00349 <span class="comment"> //! greatest common divisor</span><a name="l00350"></a>00350 <span class="comment"></span> <span class="keyword">static</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> CRYPTOPP_API Gcd(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &a, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &n);<span class="comment"></span><a name="l00351"></a>00351 <span class="comment"> //! calculate multiplicative inverse of *this mod n</span><a name="l00352"></a>00352 <span class="comment"></span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> InverseMod(<span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &n) <span class="keyword">const</span>;<span class="comment"></span><a name="l00353"></a>00353 <span class="comment"> //!</span><a name="l00354"></a>00354 <span class="comment"></span> word InverseMod(word n) <span class="keyword">const</span>;<span class="comment"></span><a name="l00355"></a>00355 <span class="comment"> //@}</span><a name="l00356"></a>00356 <span class="comment"></span><span class="comment"></span><a name="l00357"></a>00357 <span class="comment"> //! \name INPUT/OUTPUT</span><a name="l00358"></a>00358 <span class="comment"></span><span class="comment"> //@{</span><a name="l00359"></a>00359 <span class="comment"></span><span class="comment"> //!</span><a name="l00360"></a>00360 <span class="comment"></span> <span class="keyword">friend</span> CRYPTOPP_DLL std::istream& CRYPTOPP_API operator>>(std::istream& in, <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &a);<span class="comment"></span><a name="l00361"></a>00361 <span class="comment"> //!</span><a name="l00362"></a>00362 <span class="comment"></span> <span class="keyword">friend</span> CRYPTOPP_DLL std::ostream& CRYPTOPP_API operator<<(std::ostream& out, <span class="keyword">const</span> <a class="code" href="class_integer.html" title="multiple precision integer and basic arithmetics">Integer</a> &a);<span class="comment"></span><a name="l00363"></a>00363 <span class="comment"> //@}</span><a name="l00364"></a>00364 <span class="comment"></span><a name="l00365"></a>00365 <span class="keyword">private</span>:<a name="l00366"></a><a class="code" href="class_integer.html#0ef821fc78e4bfe3236b3a0157df189d">00366</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_modular_arithmetic.html" title="ring of congruence classes modulo n">ModularArithmetic</a>;<a name="l00367"></a><a class="code" href="class_integer.html#14e60a19be28337cb24783301e091877">00367</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_montgomery_representation.html" title="do modular arithmetics in Montgomery representation for increased speed">MontgomeryRepresentation</a>;<a name="l00368"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -