]> Git Repo - VerusCoin.git/blobdiff - src/arith_uint256.cpp
Cleanup and complete basic currency launch changes
[VerusCoin.git] / src / arith_uint256.cpp
index 2e613635761d8622032ff85c51f506548700f70d..deb97ac02eef2ac6e8679ce5f575b7f53ed29892 100644 (file)
@@ -1,7 +1,7 @@
 // Copyright (c) 2009-2010 Satoshi Nakamoto
 // Copyright (c) 2009-2014 The Bitcoin developers
 // Distributed under the MIT software license, see the accompanying
-// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+// file COPYING or https://www.opensource.org/licenses/mit-license.php .
 
 #include "arith_uint256.h"
 
@@ -109,6 +109,11 @@ base_uint<BITS>& base_uint<BITS>::operator/=(const base_uint& b)
 template <unsigned int BITS>
 int base_uint<BITS>::CompareTo(const base_uint<BITS>& b) const
 {
+    if ( (uint64_t)pn < 0x1000 || (uint64_t)b.pn <= 0x1000 )
+    {
+        //fprintf(stderr,"CompareTo null %p or %p\n",pn,b.pn);
+        return(0);
+    }
     for (int i = WIDTH - 1; i >= 0; i--) {
         if (pn[i] < b.pn[i])
             return -1;
@@ -173,9 +178,10 @@ unsigned int base_uint<BITS>::bits() const
 {
     for (int pos = WIDTH - 1; pos >= 0; pos--) {
         if (pn[pos]) {
-            for (int bits = 31; bits > 0; bits--) {
-                if (pn[pos] & 1 << bits)
+            for (size_t bits = 31; bits > 0; bits--) {
+                if (pn[pos] & (1U << bits)) {
                     return 32 * pos + bits + 1;
+                }
             }
             return 32 * pos + 1;
         }
This page took 0.024239 seconds and 4 git commands to generate.