btcpayserver/BTCPayServer.Rating/Extensions.cs
Kukks 587f244f1d Remove dependency on Common from Rating
replaces #1591 and #1592 , closes #1571 Replaces the Currencies.txt to a json format which includes the networks too ( there is also a test to check now) Also makes CurrencyPair not depend on network and instead use CurrencyNameTable
2020-05-31 20:54:50 +02:00

25 lines
678 B
C#

using System;
namespace BTCPayServer.Rating
{
public static class Extensions
{
public static decimal RoundToSignificant(this decimal value, ref int divisibility)
{
if (value != 0m)
{
while (true)
{
var rounded = decimal.Round(value, divisibility, MidpointRounding.AwayFromZero);
if ((Math.Abs(rounded - value) / value) < 0.001m)
{
value = rounded;
break;
}
divisibility++;
}
}
return value;
}
}
}