Exemple #1
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);
            }
        }