/// <summary> /// Rounds a double-precision floating-point value to the nearest integral value closest to the specified <paramref name="accuracy"/>. /// </summary> /// <param name="value">A double-precision floating-point number to be rounded.</param> /// <param name="accuracy">The accuracy to use in the rounding.</param> /// <returns> /// The integer value closest to the specified <paramref name="accuracy"/> of <paramref name="value"/>.<br/> /// Note that this method returns a <see cref="double"/> instead of an integral type. /// </returns> public static double RoundOff(double value, RoundOffAccuracy accuracy) { return(Math.Round(value / (long)accuracy) * (long)accuracy); }
/// <summary> /// Rounds a double-precision floating-point value to the nearest integral value closest to the specified <paramref name="accuracy"/>. /// </summary> /// <param name="value">A double-precision floating-point number to be rounded.</param> /// <param name="accuracy">The accuracy to use in the rounding.</param> /// <returns> /// The integer value closest to the specified <paramref name="accuracy"/> of <paramref name="value"/>.<br/> /// Note that this method returns a <see cref="double"/> instead of an integral type. /// </returns> public static double RoundOff(this double value, RoundOffAccuracy accuracy) { return(NumberUtility.RoundOff(value, accuracy)); }