// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { public class Program { public static double DKRound(double v) { return Math.Round(v * 2, MidpointRounding.AwayFromZero)/2; } public static decimal DKRound(decimal v) { return Math.Round(v * 2, MidpointRounding.AwayFromZero)/2; } public static void Main(string[] args) { for(double d = 1.00; d <= 2.00; d += 0.01) { Console.WriteLine(d + " -> " + DKRound(d)); } for(decimal d = 1.00m; d <= 2.00m; d += 0.01m) { Console.WriteLine(d + " -> " + DKRound(d)); } } } }