(no commit message)
authorlkcl <lkcl@web>
Wed, 27 Apr 2022 11:44:32 +0000 (12:44 +0100)
committerIkiWiki <ikiwiki.info>
Wed, 27 Apr 2022 11:44:32 +0000 (12:44 +0100)
openpower/sv/biginteger/analysis.mdwn

index 43f06e850ec26d25010512424d0123a72c0b9870..6aebf874ba59338aff851d60c0c8588b51eebc6e 100644 (file)
@@ -362,13 +362,15 @@ the digits are 32 bit and, special-casing the overflow, a 64/32 divide is suffic
         // Compute estimate qhat of q[j] from top 2 digits
         uint64_t dig2 = ((uint64_t)un[j + n] << 32) | un[j + n - 1];
         if (un[j+n] >= vn[n-1]) {
-            // rhat can be bigger than 32-bit when the division overflows,
+            // rhat can be bigger than 32-bit when the division overflows
+            qhat = UINT32_MAX;
             rhat = dig2 - (uint64_t)UINT32_MAX * vn[n - 1];
         } else {
             qhat = dig2 / vn[n - 1]; // 64/32 divide
             rhat = dig2 % vn[n - 1]; // 64/32 modulo
         }
         // use 3rd-from-top digit to obtain better accuracy
+        b = 1UL<<32;
         while (rhat < b || qhat * vn[n - 2] > b * rhat + un[j + n - 2]) {
             qhat = qhat - 1;
             rhat = rhat + vn[n - 1];