public bool Equals(double first, double second)
        {
            if (FuzzyCompare.InSameBoundary(first, second, _marginOfError, _ulpTolerance, _boundaryScale) &&
                FuzzyCompare.AreEqual(first, second, _marginOfError, _ulpTolerance))
            {
                return(true);
            }

            return(false);
        }
Beispiel #2
0
        public bool Equals(FuzzyHashedDouble other)
        {
            if (_ulpTolerance == other._ulpTolerance &&
                _marginOfError == other._marginOfError &&
                _boundaryScale == other._boundaryScale &&
                FuzzyCompare.InSameBoundary(_value, other._value, _marginOfError, _ulpTolerance, _boundaryScale) &&
                FuzzyCompare.AreEqual(_value, other._value, _marginOfError, _ulpTolerance))
            {
                return(true);
            }

            return(false);
        }
Beispiel #3
0
        /**
         * @brief This hash code algorithm produces a hash that complies with the guidelines set forth in the .NET documentation,
         * yet is able to represent a number that is capable of fuzzy logic.
         * @returns Hash for the fuzzy number.
         * */
        public override int GetHashCode()
        {
            long boundary           = FuzzyCompare.Boundary(_value, _marginOfError, _ulpTolerance, _boundaryScale);
            long valueAlongBoundary = FuzzyCompare.RoundToBoundary(_value, boundary);

            unchecked             // Overflow is fine, just wrap.
            {
                int hash = 17;
                hash = hash * 29 + valueAlongBoundary.GetHashCode();
                hash = hash * 29 + _ulpTolerance.GetHashCode();
                hash = hash * 29 + _marginOfError.GetHashCode();
                hash = hash * 29 + _boundaryScale.GetHashCode();

                return(hash);
            }
        }
Beispiel #4
0
 public bool Equals(double first, double second)
 {
     return(FuzzyCompare.AreEqual(first, second, _marginOfError, _ulpTolerance));
 }
 public bool Equals(FuzzySingle other)
 {
     return(FuzzyCompare.AreEqual(_value, other._value, _marginOfError, _ulpTolerance));
 }