public static decimal Log(this decimal value) { if (value.IsNaN()) { return(Decimals.NaN); } return(DecimalEx.Log(value)); }
public void LogarithmCalculation() { Console.WriteLine("Enter your number."); LogNumber = decimal.Parse(Console.ReadLine()); Console.WriteLine("Enter your base number."); BaseNumber = decimal.Parse(Console.ReadLine()); CalculatedLog = DecimalEx.Log(LogNumber) / DecimalEx.Log(BaseNumber); Console.WriteLine($"Your answer is {CalculatedLog}."); }
private void CalculateDewPoint() { var relativeHumidity = Humidity; var temperatureInF = Temperature; var temperatureInC = (temperatureInF - 32.0m) * 5.0m / 9.0m; var vaporPressure = relativeHumidity * 0.01m * 6.112m * DecimalEx.Exp(17.62m * temperatureInC / (temperatureInC + 243.12m)); var numerator = 243.12m * DecimalEx.Log(vaporPressure) - 440.1m; var denominator = 19.43m - DecimalEx.Log(vaporPressure); var dewPointInC = numerator / denominator; DewPoint = dewPointInC * 9.0m / 5.0m + 32.0m; }
public void RejectZeroValue() { Assert.Throws <OverflowException>(() => DecimalEx.Log(0)); }
public void RejectNegativeValue() { Assert.Throws <ArgumentException>(() => DecimalEx.Log(-1)); }
public void Test(decimal value, decimal expected, decimal tolerance) { tolerance = Helper.GetScaledTolerance(expected, (int)tolerance, true); Assert.That(DecimalEx.Log(value), Is.EqualTo(expected).Within(tolerance)); }
public void LogBaseRejectZeroValue() { Assert.Throws <OverflowException>(() => DecimalEx.Log(0, 10)); Assert.Throws <OverflowException>(() => DecimalEx.Log(10, 0)); }
public void LogBaseRejectNegativeValue() { Assert.Throws <ArgumentException>(() => DecimalEx.Log(-1, 10)); Assert.Throws <ArgumentException>(() => DecimalEx.Log(10, -1)); }
public void LogBaseRejectBaseOf1() { Assert.Throws <InvalidOperationException>(() => DecimalEx.Log(1234, 1)); }