Here's a version which passes all your test cases.
static void Main(string[] args)
{
Round(double.Epsilon, 0);
Round(0-double.Epsilon, 0);
Round(1 + double.Epsilon, 1);
Round(1 - double.Epsilon, 1);
Round(1.5, 2);
Round(2.5, 3);
Round(-1.5, -1);
Round(-2.5, -2);
Round(1.4, 1);
Round(1.6, 2);
Round(-1.4, -1);
Round(-1.6, -2);
}
private static void Round(double v1, int v2)
{
var equal = (MyRound(v1) == v2) ? "==" : "!=";
Console.WriteLine($"Math.Round({v1}) {equal} {v2}, it's {MyRound(v1)}");
}
private static double MyRound(double v1)
{
return (v1 < 0)
? 0 - Math.Round(Math.Abs(v1)-0.1)
: Math.Round(v1, MidpointRounding.AwayFromZero );
}
Output:
Math.Round(4.94065645841247E-324) == 0, it's 0
Math.Round(-4.94065645841247E-324) == 0, it's 0
Math.Round(1) == 1, it's 1
Math.Round(1) == 1, it's 1
Math.Round(1.5) == 2, it's 2
Math.Round(2.5) == 3, it's 3
Math.Round(-1.5) == -1, it's -1
Math.Round(-2.5) == -2, it's -2
Math.Round(1.4) == 1, it's 1
Math.Round(1.6) == 2, it's 2
Math.Round(-1.4) == -1, it's -1
Math.Round(-1.6) == -2, it's -2