dafis avatar dafis committed a3df83b

Fix 32-bit overflow

Comments (0)

Files changed (1)


                           k = fromIntegral (indx `shiftR` 3)
                           p = 30*k+fromIntegral (rho i)
                           q0 = (start-1) `quot` p
-                          (b0,r0) = idxPr q0
+                          (skp0,q1) = q0 `quotRem` fromIntegral sieveRange
+                          (b0,r0) = idxPr (fromIntegral q1 :: Int)
                           (b1,r1) | r0 == 7 = (b0+1,0)
                                   | otherwise = (b0,r0+1)
-                          strt0 = ((k*(30*fromIntegral b1 + fromIntegral (rho r1))
-                                        + fromIntegral b1 * fromIntegral (rho i)
+                          b2 = skp0*fromIntegral sieveBytes + fromIntegral b1
+                          strt0 = ((k*(30*b2 + fromIntegral (rho r1))
+                                        + b2 * fromIntegral (rho i)
                                         + fromIntegral (mu (moff + r1))) `shiftL` 3)
                                             + fromIntegral (nu (moff + r1))
                           strt1 = ((k*(30*k + fromIntegral (2*rho i))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.