@Markyour snippet don't match Excel calculations.In Excel, try the following values:
210.61 -> 212
2.98 -> 4
-2,98 -> -4
with you code:
210.61 -> 210
2.98 -> 2
-2,98 -> -4
I modified the code and it's working now:
public static double round_up_to_even(double number_to_round){ var converted_to_int = Convert.ToDouble(number_to_round); if (converted_to_int %2 == 0) return Math.Round(converted_to_int, 0); var difference = (converted_to_int + 1) - number_to_round; if (difference <= 0.5) return Math.Round(converted_to_int + 1, 0); var vOffset=converted_to_int < 0 ? -1 : 1; return Math.Round(converted_to_int + vOffset, 0);}