Add optimized modulo helpers for unsigned integers

This commit is contained in:
Marek Lemańczyk committed 2025-09-21 10:14:26 +02:00
1 parent 2c2bc62cb2
commit 95a0b030f6
7 files changed
+425 -84

No files matched your search

@@ -209,6 +209,30 @@ public class UInt128ExtensionsTests
value.Mod5().Should().Be((ulong)(value % 5));
}
[Fact]
[Trait("Category", "Fast")]
public void Mod7_matches_operator()
{
UInt128 value = (UInt128.One << 100) + 9876543210987654321UL;
value.Mod7().Should().Be((ulong)(value % 7));
}
[Fact]
[Trait("Category", "Fast")]
public void Mod11_matches_operator()
{
UInt128 value = (UInt128.One << 120) + 9876543210987654321UL;
value.Mod11().Should().Be((ulong)(value % 11));
}
[Fact]
[Trait("Category", "Fast")]
public void Mod128_matches_operator()
{
UInt128 value = (UInt128.One << 120) + 9876543210987654321UL;
value.Mod128().Should().Be((ulong)(value % 128));
}
[Fact]
[Trait("Category", "Fast")]
public void Mul64_matches_expected_product()