Guard GPU residue and divisor scans against overflow
This commit is contained in:
1 parent
ff2c516a0e
commit
9f2cf12ce1
2 files changed
+66
-59
No files matched your search
@@ -95,7 +95,8 @@ public sealed class MersenneNumberDivisorGpuTester
|
||||
for (k2 = 1UL; k2 <= limit; k2++)
|
||||
{
|
||||
kMul2 = (UInt128)k2 << 1;
|
||||
d = kMul2 * p + UInt128.One;
|
||||
UInt128 candidate = checked(kMul2 * p);
|
||||
d = checked(candidate + UInt128.One);
|
||||
if (p < 64UL && d == ((UInt128)1 << (int)p) - UInt128.One)
|
||||
{
|
||||
continue;
|
||||
|
||||
Reference in new issue
Block a user