Skip to content

Commit

Permalink
Try fix hamming distance calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ChainsManipulator committed Dec 3, 2024
1 parent 911f8aa commit 5e39193
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Libiada.Core.TimeSeries.OneDimensional.DistanceCalculators;

using System.Globalization;

/// <summary>
/// The hamming distance between one dimensional points calculator.
/// </summary>
Expand All @@ -19,22 +21,20 @@ public class HammingDistanceBetweenOneDimensionalPointsCalculator : IOneDimensio
/// </returns>
public double GetDistance(double firstPoint, double secondPoint)
{
string[] firstPointStringArray = firstPoint.ToString("0.00000000000000").Split(',');
string[] secondPointStringArray = secondPoint.ToString("0.00000000000000").Split(',');
string[] firstPointStringArray = firstPoint.ToString("0.00000000000000", CultureInfo.InvariantCulture).Split('.');
string[] secondPointStringArray = secondPoint.ToString("0.00000000000000", CultureInfo.InvariantCulture).Split('.');

string intPartFirst = firstPointStringArray[0];
string intPartSecond = secondPointStringArray[0];

if (firstPointStringArray[0].Length > secondPointStringArray[0].Length)

while (intPartSecond.Length != intPartFirst.Length)
{
for (int i = 0; i < firstPointStringArray[0].Length - secondPointStringArray[0].Length; i++)
if (intPartFirst.Length > intPartSecond.Length)
{
intPartSecond = $"0{intPartSecond}";
}
}
else
{
for (int i = 0; i < secondPointStringArray[0].Length - firstPointStringArray[0].Length; i++)
else
{
intPartFirst = $"0{intPartFirst}";
}
Expand Down

0 comments on commit 5e39193

Please sign in to comment.