Added Unit Tests

This commit is contained in:
2023-04-20 16:56:41 +02:00
parent d4e217efad
commit 93abb5d308
6 changed files with 82 additions and 7 deletions

View File

@ -108,17 +108,17 @@ namespace Elwig.Helpers {
}
public static double OeToKmw(double oe) {
return Math.Round((-4.54 + Math.Sqrt(4.54 * 4.54 - 4 * 0.022 * -oe)) / 2 * 0.022, 1);
return Math.Round((-4.54 + Math.Sqrt(4.54 * 4.54 - 4 * 0.022 * -oe)) / (2 * 0.022), 1);
}
public static decimal DecFromDb(long value, byte precision) {
bool neg = value < 0;
if (neg) value = -value;
return new decimal((int)(value & 0xFFFFFFFF), (int)((value >> 32) & 0x7FFFFFFF), 0, neg, precision);
if (neg) value = -value;
return new((int)(value & 0xFFFFFFFF), (int)((value >> 32) & 0x7FFFFFFF), 0, neg, precision);
}
public static long DecToDb(decimal value, byte precision) {
return (long)decimal.Round(value * precision, 0);
return (long)decimal.Round(value * (decimal)Math.Pow(10, precision), 0);
}
}
}