Smaller optimizations. Division by zero fixed?

This commit is contained in:
mlemanczyk committed 2025-10-17 14:18:49 +02:00
1 parent 5fcd082fff
commit 43cf4a978f
3 files changed
+55 -46

No files matched your search

+6 -5
View File
@@ -330,11 +330,12 @@ public static class ULongExtensions
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ulong Pow2MontgomeryModWindowedCpu(this ulong exponent, in MontgomeryDivisorData divisor, bool keepMontgomery)
{
ulong modulus = divisor.Modulus;
if (exponent == 0UL)
{
return keepMontgomery ? divisor.MontgomeryOne : 1UL % modulus;
}
ulong modulus = divisor.Modulus;
// This should never happen in production code. If it does, we need to fix it.
// if (exponent == 0UL)
// {
// return keepMontgomery ? divisor.MontgomeryOne : 1UL % modulus;
// }
if (exponent <= Pow2WindowFallbackThreshold)
{