Skip to content

Commit 454588d

Browse files
committed
renamed Pow10 to Factor
1 parent a148b15 commit 454588d

4 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/PolylineAlgorithm/FormatterBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public FormatterBuilder<TValue, TPolyline> AddValue(string name, Func<TValue, do
8181
throw new ArgumentException($"A rule with the name '{name}' has already been added.", nameof(name));
8282
}
8383

84-
_rules.Add(new FormatterRule<TValue>(name, (long)Pow10.GetFactor(precision), selector));
84+
_rules.Add(new FormatterRule<TValue>(name, (long)Factor.Get(precision), selector));
8585

8686
return this;
8787
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ namespace PolylineAlgorithm.Internal;
99
/// This class caches common powers of 10 (10^0 through 10^9) for efficient lookup,
1010
/// falling back to <see cref="Math.Pow"/> for larger exponents.
1111
/// </remarks>
12-
internal static class Pow10 {
12+
internal static class Factor {
1313
/// <summary>
1414
/// Pre-computed powers of 10 from 10^0 to 10^9.
1515
/// </summary>
16-
private static readonly uint[] _pow10 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000];
16+
private static readonly uint[] _factors = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000];
1717

1818
/// <summary>
1919
/// Returns the power of 10 for the specified precision level.
@@ -32,9 +32,9 @@ internal static class Pow10 {
3232
/// <exception cref="OverflowException">
3333
/// Thrown if the computed value exceeds <see cref="uint.MaxValue"/>.
3434
/// </exception>
35-
public static uint GetFactor(uint precision) {
35+
public static uint Get(uint precision) {
3636
checked {
37-
return precision < _pow10.Length ? _pow10[precision] : (uint)Math.Pow(10, precision);
37+
return precision < _factors.Length ? _factors[precision] : (uint)Math.Pow(10, precision);
3838
}
3939
}
4040
}

src/PolylineAlgorithm/PolylineEncoding.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static long Normalize(double value, uint precision = 5) {
7171
return (long)Math.Truncate(value);
7272
}
7373

74-
uint factor = Pow10.GetFactor(precision);
74+
uint factor = Factor.Get(precision);
7575

7676
const double Epsilon = 1e-9;
7777

@@ -126,7 +126,7 @@ public static double Denormalize(long value, uint precision = 5) {
126126
return value;
127127
}
128128

129-
uint factor = Pow10.GetFactor(precision);
129+
uint factor = Factor.Get(precision);
130130

131131
checked {
132132

tests/PolylineAlgorithm.Tests/Internal/Pow10Tests.cs renamed to tests/PolylineAlgorithm.Tests/Internal/FactorTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ namespace PolylineAlgorithm.Tests.Internal;
88
using PolylineAlgorithm.Internal;
99

1010
/// <summary>
11-
/// Tests for <see cref="Pow10"/>.
11+
/// Tests for <see cref="Factor"/>.
1212
/// </summary>
1313
[TestClass]
14-
public sealed class Pow10Tests {
14+
public sealed class FactorTests {
1515
/// <summary>
16-
/// Tests that GetFactor returns the correct power-of-ten factor for the given precision.
16+
/// Tests that Get returns the correct power-of-ten factor for the given precision.
1717
/// </summary>
1818
[TestMethod]
1919
[DataRow(0u, 1u)]
@@ -26,24 +26,24 @@ public sealed class Pow10Tests {
2626
[DataRow(7u, 10000000u)]
2727
[DataRow(8u, 100000000u)]
2828
[DataRow(9u, 1000000000u)]
29-
public void GetFactor_With_Valid_Precision_Returns_Expected_Value(uint precision, uint expected) {
29+
public void Get_With_Valid_Precision_Returns_Expected_Value(uint precision, uint expected) {
3030
// Act
31-
uint result = Pow10.GetFactor(precision);
31+
uint result = Factor.Get(precision);
3232

3333
// Assert
3434
Assert.AreEqual(expected, result);
3535
}
3636

3737
/// <summary>
38-
/// Tests that GetFactor throws <see cref="OverflowException"/> when precision causes overflow.
38+
/// Tests that Get throws <see cref="OverflowException"/> when precision causes overflow.
3939
/// </summary>
4040
[TestMethod]
4141
[DataRow(10u)]
4242
[DataRow(15u)]
4343
[DataRow(20u)]
4444
[DataRow(uint.MaxValue)]
45-
public void GetFactor_With_Overflowing_Precision_Throws_OverflowException(uint precision) {
45+
public void Get_With_Overflowing_Precision_Throws_OverflowException(uint precision) {
4646
// Act & Assert
47-
Assert.ThrowsExactly<OverflowException>(() => Pow10.GetFactor(precision));
47+
Assert.ThrowsExactly<OverflowException>(() => Factor.Get(precision));
4848
}
4949
}

0 commit comments

Comments
 (0)