using System; using System.Linq; public class Test { private static double Convert(double a) { return ((a + 360) % 360 + 360) % 360 - (int)(((a + 360) % 360 + 360) % 360 / 180 - 1e-12) * 360; } public static void Main() { double[] a = { 0, 32, 70, 90, 150, 179, 180, 186, 190, 270, 350, 360, 400, -45, -90, -179, -180, -181, -270, -359, -360 }; Console.WriteLine(String.Join("\n", a.Select(x => new { Original=x, Result=Convert(x) }))); } }