using System;

namespace MECF.Framework.Common.MECF.Framework.Common.Utilities
{
    /// <summary>
    /// 
    /// </summary>
    public static class DoubleUtil
    {
        private const double TOLERANCE = 0.000001;

        /// <summary>
        /// 判断指定的两个double数字是否相等。
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        public static bool IsEqual(double a, double b, double tolerance = TOLERANCE)
        {
            return !(Math.Abs(a - b) > tolerance);
        }

        /// <summary>
        /// 判断指定的两个double数字是否不相等。
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <param name="tolerance"></param>
        /// <returns></returns>
        public static bool NotEqual(double a, double b, double tolerance = TOLERANCE)
        {
            return Math.Abs(a - b) > tolerance;
        }
    }
}
