Free cookie consent management tool by TermsFeed Policy Generator

source: branches/MCTS-SymbReg-2796/HeuristicLab.Algorithms.DataAnalysis/3.4/MctsSymbolicRegression/ApproximateDoubleEqualityComparer.cs @ 15414

Last change on this file since 15414 was 15414, checked in by gkronber, 6 years ago

#2796 worked on MCTS

File size: 692 bytes
Line 
1using System;
2using System.Collections.Generic;
3
4namespace HeuristicLab.Algorithms.DataAnalysis.MctsSymbolicRegression {
5  internal class ApproximateDoubleEqualityComparer : IEqualityComparer<double> {
6    public bool Equals(double x, double y) {
7      // TODO: check
8      var xl = (ulong)BitConverter.DoubleToInt64Bits(x);
9      var yl = (ulong)BitConverter.DoubleToInt64Bits(y);
10
11      xl = xl & 0xFFFFFFFFFFFFFFE0;
12      yl = yl & 0xFFFFFFFFFFFFFFE0;
13
14      return xl == yl;
15    }
16
17    public int GetHashCode(double obj) {
18      var bits = (ulong)BitConverter.DoubleToInt64Bits(obj);
19
20      bits = bits & 0xFFFFFFFFFFFFFFE0;
21
22      return (int)bits;
23    }
24  }
25}
Note: See TracBrowser for help on using the repository browser.