Benchmarks extended. Small optimizations.

This commit is contained in:
Marek Lemańczyk committed 2025-09-21 06:15:14 +02:00
1 parent 53554ffd3d
commit 1499f6abe1
5 files changed
+181 -79

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
using System.Runtime.CompilerServices;
namespace PerfectNumbers.Core;
public static class PerfectNumbersMath
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint FastRemainder3(uint value)
{
uint quotient = (uint)(((ulong)value * 0xAAAAAAABUL) >> 33);
return value - quotient * 3U;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint FastRemainder5(uint value)
{
uint quotient = (uint)(((ulong)value * 0xCCCCCCCDUL) >> 34);
return value - quotient * 5U;
}
}