Skip to content

Commit 8286453

Browse files
committed
fixed rounding
1 parent 58f1a53 commit 8286453

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/PolylineAlgorithm/PolylineEncoding.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public bool TryReadValue(ref int variance, ref ReadOnlyMemory<char> buffer, ref
5454
/// <param name="value">The normalized integer value.</param>
5555
/// <returns>The denormalized double value.</returns>
5656
[MethodImpl(MethodImplOptions.AggressiveInlining)]
57-
public double Denormalize(int value) => Math.Round((double)value / Defaults.Algorithm.Precision, 5);
57+
public double Denormalize(int value) => Math.Truncate((double)value) / Defaults.Algorithm.Precision;
5858

5959
/// <summary>
6060
/// Attempts to write an encoded value to the buffer.
@@ -93,7 +93,7 @@ public bool TryWriteValue(int variance, ref Span<char> buffer, ref int position)
9393
/// <param name="value">The double value to normalize.</param>
9494
/// <returns>The normalized integer value.</returns>
9595
[MethodImpl(MethodImplOptions.AggressiveInlining)]
96-
public int Normalize(double value) => (int)Math.Truncate(value * Defaults.Algorithm.Precision);
96+
public int Normalize(double value) => (int)Math.Round(value * Defaults.Algorithm.Precision);
9797

9898
/// <summary>
9999
/// Calculates the number of characters required to encode a given variance.

0 commit comments

Comments
 (0)