internal static Size Round(Size size, RoundingMode roundingMode, int digits = 0) { var width = DoubleUtils.Round(size.Width, digits, roundingMode); var height = DoubleUtils.Round(size.Height, digits, roundingMode); return(new Size(width, height)); }
protected override object ConvertCore(object value, Type targetType, object parameter, CultureInfo culture) { var roundingMode = RoundingMode.MidPointFromZero; if (value is double) { var dblValue = (double)value; return(DoubleUtils.Round(dblValue, Digits, roundingMode)); } if (value is Point) { var ptValue = (Point)value; return(PointUtils.Round(ptValue, roundingMode, Digits)); } if (value is Size) { var szValue = (Size)value; return(SizeUtils.Round(szValue, roundingMode, Digits)); } if (value is Rect) { var rcValue = (Rect)value; return(RectUtils.Round(rcValue, roundingMode, Digits)); } return(value); }
public void DoubleUtils_Round1() { double?double1 = new double?(1.0); long? result = DoubleUtils.Round(double1); Assert.IsNotNull(result); Assert.AreEqual((byte)1, (byte)result); Assert.AreEqual((short)1, (short)result); Assert.AreEqual(1, (int)result); Assert.AreEqual(1L, (long)result); Assert.AreEqual(1.0f, (float)result, 1.0f); Assert.AreEqual(1.0, (long)result, 1.0); Assert.AreEqual("1", result.Value.ToString("0", CultureInfo.InvariantCulture)); }
private static double FinalRound(double value) { return(DoubleUtils.Round(value, 2, RoundingMode.MidPointToEven)); }
public double RoundY(double value, RoundingMode roundingMode) { return(DoubleUtils.Round(value, roundingMode)); }
public double RoundY(double value, RoundingMode roundingMode) { return(FinalRound(DownScaleY(DoubleUtils.Round(UpScaleY(value), roundingMode)))); }
private static double Calc(double value, double gridStep, bool visible) { return(visible ? gridStep * DoubleUtils.Round(value / gridStep, RoundingMode.MidPointFromZero) : value); }
internal static double RoundMidPointToEven(this double self, int precision) { return(DoubleUtils.Round(self, precision, RoundingMode.MidPointToEven)); }
internal static double RoundMidPointFromZero(this double self) { return(DoubleUtils.Round(self, RoundingMode.MidPointFromZero)); }
internal static double RoundFromZero(this double self, int precision) { return(DoubleUtils.Round(self, precision, RoundingMode.FromZero)); }
internal static double RoundToZero(this double self) { return(DoubleUtils.Round(self, RoundingMode.ToZero)); }