Reapply modulo helpers and inline fast remainders

This commit is contained in:
Marek Lemańczyk committed 2025-09-22 19:26:07 +02:00
1 parent 5db0c4fa95
commit ca866ffc5b
43 files changed
+982 -134

No files matched your search

@@ -201,6 +201,14 @@ public class UInt128ExtensionsTests
value.Mod3().Should().Be((ulong)(value % 3));
}
[Fact]
[Trait("Category", "Fast")]
public void Mod6_matches_operator()
{
UInt128 value = (UInt128.One << 100) + 9876543210UL;
value.Mod6().Should().Be((ulong)(value % 6));
}
[Fact]
[Trait("Category", "Fast")]
public void Mod5_matches_operator()
@@ -27,6 +27,17 @@ public class UIntExtensionsTests
value.Mod5().Should().Be(value % 5U);
}
[Theory]
[Trait("Category", "Fast")]
[InlineData(0U)]
[InlineData(1U)]
[InlineData(1234567890U)]
[InlineData(uint.MaxValue)]
public void Mod6_matches_operator(uint value)
{
value.Mod6().Should().Be(value % 6U);
}
[Theory]
[Trait("Category", "Fast")]
[InlineData(0U)]
@@ -41,6 +41,16 @@ public class ULongExtensionsTests
value.Mod5().Should().Be(value % 5UL);
}
[Theory]
[Trait("Category", "Fast")]
[InlineData(0UL)]
[InlineData(ulong.MaxValue)]
[InlineData(1234567890123456789UL)]
public void Mod6_matches_operator(ulong value)
{
value.Mod6().Should().Be(value % 6UL);
}
[Theory]
[Trait("Category", "Fast")]
[InlineData(0UL)]
@@ -101,6 +111,22 @@ public class ULongExtensionsTests
step3.Should().Be(expected3);
}
[Theory]
[Trait("Category", "Fast")]
[InlineData(0UL)]
[InlineData(1UL)]
[InlineData(1234567890123456789UL)]
[InlineData(ulong.MaxValue)]
public void Mod11_7_5_3_matches_operator(ulong value)
{
value.Mod11_7_5_3(out ulong mod11, out ulong mod7, out ulong mod5, out ulong mod3);
mod11.Should().Be(value % 11UL);
mod7.Should().Be(value % 7UL);
mod5.Should().Be(value % 5UL);
mod3.Should().Be(value % 3UL);
}
[Theory]
[Trait("Category", "Fast")]
[InlineData(2UL, true)]