Added Unit Tests
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user