using System; using System.Collections.Generic; namespace HeuristicLab.Algorithms.DataAnalysis.MctsSymbolicRegression { // unused? internal class ApproximateDoubleEqualityComparer : IEqualityComparer { public bool Equals(double x, double y) { // TODO: check var xl = (ulong)BitConverter.DoubleToInt64Bits(x); var yl = (ulong)BitConverter.DoubleToInt64Bits(y); xl = xl & 0xFFFFFFFFFFFFFFE0; // ignore least significant bits yl = yl & 0xFFFFFFFFFFFFFFE0; return xl == yl; } public int GetHashCode(double obj) { var bits = (ulong)BitConverter.DoubleToInt64Bits(obj); bits = bits & 0xFFFFFFFFFFFFFFE0; // ignore least significant bits return (int)bits; } } }