Hoist by-divisor invariants and split mod-8 updates

This commit is contained in:
Marek Lemańczyk committed 2025-10-27 16:48:02 +01:00
1 parent 1bd3d5c163
commit 0466d98434
7 files changed
+116 -126

No files matched your search

+7 -2
View File
@@ -7,6 +7,12 @@ internal static class DivisorGenerator
private const ushort DecimalMaskWhenLastIsSeven = (1 << 3) | (1 << 7) | (1 << 9);
private const ushort DecimalMaskOtherwise = (1 << 1) | (1 << 3) | (1 << 9);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ushort GetDecimalMask(LastDigit lastDigit)
{
return lastDigit == LastDigit.Seven ? DecimalMaskWhenLastIsSeven : DecimalMaskOtherwise;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsValidDivisor(
byte remainder10,
@@ -15,9 +21,8 @@ internal static class DivisorGenerator
byte remainder5,
byte remainder7,
byte remainder11,
LastDigit lastDigit)
ushort decimalMask)
{
ushort decimalMask = lastDigit == LastDigit.Seven ? DecimalMaskWhenLastIsSeven : DecimalMaskOtherwise;
if (((decimalMask >> remainder10) & 1) == 0)
{
return false;