Skip to content

Commit d791392

Browse files
committed
fixed normalization
1 parent c83fc81 commit d791392

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/PolylineAlgorithm/PolylineEncoding.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright © Pete Sramek. All rights reserved.
33
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
44
//
@@ -76,10 +76,11 @@ public static int Normalize(double value, uint precision = 5) {
7676

7777
uint factor = Pow10.GetFactor(precision);
7878

79+
const double Epsilon = 1e-9;
80+
7981
checked {
80-
return (int)(Math.Truncate(value * 10 * factor) / 10);
82+
return (int)Math.Truncate((value * factor) + (Epsilon * Math.Sign(value)));
8183
}
82-
8384
}
8485

8586
/// <summary>

0 commit comments

Comments
 (0)