Inconsistency with Math.Round()
I have two functions that are intended to contain angles between (-180,180] and (-π,π]. The intent is that given any angle from -inf to +inf it will retain the equivalent angle in the intervals specified. For example the angle for 1550° is 110°. public double WrapBetween180(double angle) { return angle - 360d * Math.Round(angle / 360d, MidpointRounding.AwayFromZero); } public double WrapBetweenPI(double angle) { const double twopi = 2d * Math.PI; return angle - twopi * Math.Round(angle / twopi, MidpointRounding.AwayFromZero); } which yields the following results WrapBetween180(-180) = -180