fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var tests = new List<double> { 131.505, 131.515, 131.525, 131.535, 131.545, 131.555, 131.565, 131.575, 131.585, 131.595 };
  9. foreach (double n in tests)
  10. {
  11. Console.WriteLine("{0} => {1}", n, Math.Round(n, 2, MidpointRounding.ToEven));
  12. }
  13. }
  14. }
  15.  
Success #stdin #stdout 0.02s 131520KB
stdin
Standard input is empty
stdout
131.505 => 131.5
131.515 => 131.51
131.525 => 131.52
131.535 => 131.54
131.545 => 131.54
131.555 => 131.56
131.565 => 131.56
131.575 => 131.57
131.585 => 131.58
131.595 => 131.6