Skip to content

Commit 269527f

Browse files
committed
Fix comments
1 parent 68e0f0e commit 269527f

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/libraries/System.Runtime.Numerics/src/System/Number.BigInteger.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,20 +1136,18 @@ public static PowersOf1e9 GetCached(int bufferLength)
11361136
nuint[] buffer = new nuint[bufferLength];
11371137
Build(buffer, cached ?? LeadingPowers1E9);
11381138

1139-
// The write is safe without explicit memory barriers because:
1140-
// 1. The array is fully initialized before being stored.
1141-
// 2. On ARM64, the .NET GC write barrier uses stlr (store-release),
1142-
// providing release semantics for reference-type stores.
1143-
// 3. Readers have a data dependency (load reference -> access elements),
1144-
// providing natural acquire ordering on all architectures.
1139+
// reftype field assignments have Store-Release semantics in .NET, so no volatile is needed.
11451140
s_cachedPowersOf1e9 = buffer;
11461141
return new(buffer);
11471142
}
11481143

11491144
/// <summary>
11501145
/// Pre-calculated cumulative lengths into <see cref="pow1E9"/>.
1151-
/// <c>pow1E9[Indexes[i-1]..Indexes[i]]</c> equals <c>1000000000^(1&lt;&lt;i)</c>.
1146+
/// <c>pow1E9[Indexes[i]..Indexes[i+1]]&lt;&lt;(32*OmittedLength(i))</c> equals <c>1e9^(1&lt;&lt;i)</c>.
11521147
/// </summary>
1148+
/// <remarks>
1149+
/// Satisfies the following relationship <c>Indexes[i+1] - Indexes[i] == Math.Ceiling(Math.Log2(1e9) * (1u&lt;&lt;i) / 32 - OmittedLength(i))</c>.
1150+
/// </remarks>
11531151
private static ReadOnlySpan<int> Indexes => nint.Size == 8 ? Indexes64 : Indexes32;
11541152

11551153
private static ReadOnlySpan<int> Indexes32 =>
@@ -1225,8 +1223,7 @@ public static PowersOf1e9 GetCached(int bufferLength)
12251223
];
12261224

12271225
/// <summary>
1228-
/// Pre-computed leading powers of 10^9 for small exponents. Entries up to
1229-
/// <c>1000000000^(1&lt;&lt;5)</c> are stored directly because their low limb is never zero.
1226+
/// Pre-computed leading powers of 10^9 for small exponents.
12301227
/// </summary>
12311228
private static ReadOnlySpan<nuint> LeadingPowers1E9 => nint.Size == 8
12321229
? MemoryMarshal.Cast<ulong, nuint>(LeadingPowers1E9_64)

0 commit comments

Comments
 (0)