diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2005-07-12 04:23:32 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2005-07-12 04:23:32 +0000 |
commit | d5ebf62bed594d1fe6ab616a6bbcbcf0a5892d47 (patch) | |
tree | 4b03760892a97a9bc452ebe8b7793bbebd402ad4 /nbtheory.cpp | |
parent | fa39f51809b4da54a5c2adb3e183b1a625cefb92 (diff) | |
download | cryptopp-d5ebf62bed594d1fe6ab616a6bbcbcf0a5892d47.tar.gz |
port to MSVC .NET 2005 beta 2
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@198 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'nbtheory.cpp')
-rw-r--r-- | nbtheory.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/nbtheory.cpp b/nbtheory.cpp index 1251423..97689bd 100644 --- a/nbtheory.cpp +++ b/nbtheory.cpp @@ -37,7 +37,7 @@ struct NewPrimeTable if (j == testEntriesEnd) { primeTable.push_back(p); - testEntriesEnd = STDMIN((size_t)54U, primeTable.size()); + testEntriesEnd = UnsignedMin(54U, primeTable.size()); } } @@ -48,7 +48,7 @@ struct NewPrimeTable const word16 * GetPrimeTable(unsigned int &size) { const std::vector<word16> &primeTable = Singleton<std::vector<word16>, NewPrimeTable>().Ref(); - size = primeTable.size(); + size = (unsigned int)primeTable.size(); return &primeTable[0]; } @@ -303,10 +303,11 @@ PrimeSieve::PrimeSieve(const Integer &first, const Integer &last, const Integer bool PrimeSieve::NextCandidate(Integer &c) { - m_next = std::find(m_sieve.begin()+m_next, m_sieve.end(), false) - m_sieve.begin(); + bool safe = SafeConvert(std::find(m_sieve.begin()+m_next, m_sieve.end(), false) - m_sieve.begin(), m_next); + assert(safe); if (m_next == m_sieve.size()) { - m_first += m_sieve.size()*m_step; + m_first += long(m_sieve.size())*m_step; if (m_first > m_last) return false; else @@ -328,7 +329,7 @@ void PrimeSieve::SieveSingle(std::vector<bool> &sieve, word16 p, const Integer & { if (stepInv) { - unsigned int sieveSize = sieve.size(); + size_t sieveSize = sieve.size(); word j = word((word32(p-(first%p))*stepInv) % p); // if the first multiple of p is p, skip it if (first.WordCount() <= 1 && first + step*j == p) @@ -549,6 +550,19 @@ Integer CRT(const Integer &xp, const Integer &p, const Integer &xq, const Intege { // isn't operator overloading great? return p * (u * (xq-xp) % q) + xp; +/* + Integer t1 = xq-xp; + cout << hex << t1 << endl; + Integer t2 = u * t1; + cout << hex << t2 << endl; + Integer t3 = t2 % q; + cout << hex << t3 << endl; + Integer t4 = p * t3; + cout << hex << t4 << endl; + Integer t5 = t4 + xp; + cout << hex << t5 << endl; + return t5; +*/ } Integer CRT(const Integer &xp, const Integer &p, const Integer &xq, const Integer &q) |