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