Skip to content

Commit

Permalink
doubles performance
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyLloyd committed Nov 30, 2023
1 parent 09dff27 commit fd68d1c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CsCheck/Check.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3222,7 +3222,8 @@ public override string ToString()
spinLock.Enter(ref lockTaken);
if (!processing)
{
var result = $"{Median.Median * 100.0:#0.00}%[{Median.Q1 * 100.0:#0.00}%..{Median.Q3 * 100.0:#0.00}%] {(Median.Median >= 0.0 ? "faster" : "slower")}";
var times = 1 / (1 - Math.Abs(Median.Median));
var result = $"{Median.Median * 100.0:#0.00}%[{Median.Q1 * 100.0:#0.00}%..{Median.Q3 * 100.0:#0.00}%] {times:#0.00}x {(Median.Median >= 0.0 ? "faster" : "slower")}";
if (double.IsNaN(Median.Median)) result = $"Time resolution too small try using repeat.\n{result}";
else if ((Median.Median >= 0.0) != (Faster > Slower)) result = $"Inconsistent result try using repeat or increasing sigma.\n{result}";
result = $"{result}, sigma={Math.Sqrt(SigmaSquared):#0.0} ({Faster:#,0} vs {Slower:#,0})";
Expand Down
10 changes: 10 additions & 0 deletions Tests/FloatingPointTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public void DoubleSupportsRoundtripPrecisionTo15()
}, writeLine: output.WriteLine);
}

[Fact]
public void X()
{
var quantity = 1000;
var price = 99.99;
var fxRate = 1.2345;
var localValue = MathX.TwoMul(quantity, price, out double lo1);
var usdValue = MathX.TwoMul(localValue, fxRate, out double lo2);
}

private static void DoubleSumPrecision(int significantFigures, int maxLength)
{
const double scaling = 0.01;
Expand Down

0 comments on commit fd68d1c

Please sign in to comment.