operators refactoring
.NET Test / .NET tests (push) Successful in 2m11s

This commit is contained in:
2026-09-24 00:39:59 +04:00
parent 3de9457fdc
commit ac93744579
26 changed files with 651 additions and 334 deletions
@@ -3,7 +3,7 @@ namespace Just.PreciseMath.Tests;
public class DoubleDoubleRootFunctionsTests
{
[Fact]
public void ExistingRootsAreAvailableOnTheTypeAndMatchFacadeBits()
public void RootsAreCanonicalAndSqrtMatchesGenericDispatchBits()
{
DoubleDouble[] values = [DoubleDouble.Zero, DoubleDouble.NegativeZero,
DoubleDouble.NaN, DoubleDouble.PositiveInfinity, DoubleDouble.NegativeInfinity,
@@ -11,11 +11,16 @@ public class DoubleDoubleRootFunctionsTests
DoubleDouble.FromComponents(1.0, Math.ScaleB(1.0, -1000))];
foreach (DoubleDouble value in values)
{
AssertBits(DDMath.Sqrt(value), DoubleDouble.Sqrt(value));
AssertBits(DDMath.InvSqrt(value), DoubleDouble.InvSqrt(value));
AssertBits(DoubleDouble.Sqrt(value), GenericSqrt(value));
DoubleDouble.IsCanonical(DoubleDouble.InvSqrt(value)).ShouldBeTrue();
}
}
private static T GenericSqrt<T>(T value) where T : IRootFunctions<T>
{
return T.Sqrt(value);
}
private static void AssertBits(DoubleDouble expected, DoubleDouble actual)
{
BitConverter.DoubleToInt64Bits(actual.High).ShouldBe(BitConverter.DoubleToInt64Bits(expected.High));