Files
Just.PreciseMath/1-tests/Just.PreciseMath.Tests/DoubleDoubleRootFunctionsTests.cs
T
just 7084fae174
.NET Test / .NET tests (push) Successful in 1m31s
added root functions
2026-09-16 20:24:08 +04:00

28 lines
1.0 KiB
C#

using Shouldly;
using Xunit;
namespace Just.PreciseMath.Tests;
public class DoubleDoubleRootFunctionsTests
{
[Fact]
public void ExistingRootsAreAvailableOnTheTypeAndMatchFacadeBits()
{
DoubleDouble[] values = [DoubleDouble.Zero, DoubleDouble.NegativeZero,
DoubleDouble.NaN, DoubleDouble.PositiveInfinity, DoubleDouble.NegativeInfinity,
new(-1.0), new(double.Epsilon), new(2.0), new(double.MaxValue),
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));
}
}
private static void AssertBits(DoubleDouble expected, DoubleDouble actual)
{
BitConverter.DoubleToInt64Bits(actual.High).ShouldBe(BitConverter.DoubleToInt64Bits(expected.High));
BitConverter.DoubleToInt64Bits(actual.Low).ShouldBe(BitConverter.DoubleToInt64Bits(expected.Low));
}
}