From 8541706a3331db8e72edde893a7ce5c4532e23ec Mon Sep 17 00:00:00 2001 From: konard Date: Sat, 13 Sep 2025 14:12:20 +0300 Subject: [PATCH 1/3] Initial commit with task details for issue #90 Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: https://github.com/linksplatform/Numbers/issues/90 --- CLAUDE.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..8028110 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,5 @@ +Issue to solve: https://github.com/linksplatform/Numbers/issues/90 +Your prepared branch: issue-90-bdd0703d +Your prepared working directory: /tmp/gh-issue-solver-1757761936380 + +Proceed. \ No newline at end of file From 3aaf7a3de0231fc0472bdbf752e1b3d92cf5df21 Mon Sep 17 00:00:00 2001 From: konard Date: Sat, 13 Sep 2025 14:25:53 +0300 Subject: [PATCH 2/3] Fix LGTM alerts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add missing XML documentation for Bit.PartialRead method - Replace hardcoded bit size constants (32) with BitsSize field - Fix IsPowerOfTwo method to correctly handle zero values (zero is not a power of two) - Fix incorrect usage of MaximumCatalanIndex in Factorial method, should use MaximumFactorialNumber - Update version to 0.9.1 and release notes πŸ€– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- csharp/Platform.Numbers/Bit[T].cs | 53 ++++++++++++++++--- csharp/Platform.Numbers/Math.cs | 4 +- .../Platform.Numbers/Platform.Numbers.csproj | 4 +- 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/csharp/Platform.Numbers/Bit[T].cs b/csharp/Platform.Numbers/Bit[T].cs index 8e8b752..e74a459 100644 --- a/csharp/Platform.Numbers/Bit[T].cs +++ b/csharp/Platform.Numbers/Bit[T].cs @@ -18,33 +18,74 @@ public static class Bit where T : INumberBase, IShiftOperators private static int BitsSize = NumericType.BitsSize; /// - /// + /// Writes a portion of the source value into the target value at the specified bit position. + /// ЗаписываСт Ρ‡Π°ΡΡ‚ΡŒ исходного значСния Π² Ρ†Π΅Π»Π΅Π²ΠΎΠ΅ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ Π² ΡƒΠΊΠ°Π·Π°Π½Π½ΠΎΠΉ Π±ΠΈΡ‚ΠΎΠ²ΠΎΠΉ ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ. /// - /// + /// + /// The target value to write to. + /// Π¦Π΅Π»Π΅Π²ΠΎΠ΅ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ для записи. + /// + /// + /// The source value to read from. + /// Π˜ΡΡ…ΠΎΠ΄Π½ΠΎΠ΅ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ для чтСния. + /// + /// + /// The bit position to start writing at. + /// Битовая позиция для Π½Π°Ρ‡Π°Π»Π° записи. + /// + /// + /// The number of bits to write. + /// ΠšΠΎΠ»ΠΈΡ‡Π΅ΡΡ‚Π²ΠΎ Π±ΠΈΡ‚ΠΎΠ² для записи. + /// + /// + /// The target value with the specified bits updated. + /// Π¦Π΅Π»Π΅Π²ΠΎΠ΅ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ с ΠΎΠ±Π½ΠΎΠ²Π»Π΅Π½Π½Ρ‹ΠΌΠΈ ΡƒΠΊΠ°Π·Π°Π½Π½Ρ‹ΠΌΠΈ Π±ΠΈΡ‚Π°ΠΌΠΈ. + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T PartialWrite(T target, T source, int shift, int limit) { if (shift < 0) { - shift = 32 + shift; + shift = BitsSize + shift; } if (limit < 0) { - limit = 32 + limit; + limit = BitsSize + limit; } var sourceMask = ~(T.MaxValue << limit) & T.MaxValue; var targetMask = ~(sourceMask << shift); return target & targetMask | (source & sourceMask) << shift; } + + /// + /// Reads a portion of bits from the target value at the specified bit position. + /// Π§ΠΈΡ‚Π°Π΅Ρ‚ Ρ‡Π°ΡΡ‚ΡŒ Π±ΠΈΡ‚ΠΎΠ² ΠΈΠ· Ρ†Π΅Π»Π΅Π²ΠΎΠ³ΠΎ значСния Π² ΡƒΠΊΠ°Π·Π°Π½Π½ΠΎΠΉ Π±ΠΈΡ‚ΠΎΠ²ΠΎΠΉ ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ. + /// + /// + /// The target value to read from. + /// Π¦Π΅Π»Π΅Π²ΠΎΠ΅ Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ для чтСния. + /// + /// + /// The bit position to start reading from. + /// Битовая позиция для Π½Π°Ρ‡Π°Π»Π° чтСния. + /// + /// + /// The number of bits to read. + /// ΠšΠΎΠ»ΠΈΡ‡Π΅ΡΡ‚Π²ΠΎ Π±ΠΈΡ‚ΠΎΠ² для чтСния. + /// + /// + /// The extracted bits as a value. + /// Π˜Π·Π²Π»Π΅Ρ‡Π΅Π½Π½Ρ‹Π΅ Π±ΠΈΡ‚Ρ‹ Π² Π²ΠΈΠ΄Π΅ значСния. + /// public static T PartialRead(T target, int shift, int limit) { if (shift < 0) { - shift = 32 + shift; + shift = BitsSize + shift; } if (limit < 0) { - limit = 32 + limit; + limit = BitsSize + limit; } var sourceMask = ~(T.MaxValue << limit) & T.MaxValue; var targetMask = sourceMask << shift; diff --git a/csharp/Platform.Numbers/Math.cs b/csharp/Platform.Numbers/Math.cs index 84a48b7..47fa9d4 100644 --- a/csharp/Platform.Numbers/Math.cs +++ b/csharp/Platform.Numbers/Math.cs @@ -52,7 +52,7 @@ public static class Math /// public static TLinkAddress Factorial(TLinkAddress n) where TLinkAddress : IUnsignedNumber, IComparisonOperators { - if (n >= TLinkAddress.Zero && n <= TLinkAddress.CreateTruncating(MaximumCatalanIndex)) + if (n >= TLinkAddress.Zero && n <= TLinkAddress.CreateTruncating(MaximumFactorialNumber)) { return TLinkAddress.CreateTruncating(_factorials[ulong.CreateTruncating(n)]); } @@ -101,7 +101,7 @@ public static TLinkAddress Catalan(TLinkAddress n) where TLinkAddr [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsPowerOfTwo(TLinkAddress x) where TLinkAddress : IUnsignedNumber, IBitwiseOperators, IComparisonOperators { - return (x & x - TLinkAddress.One) == TLinkAddress.Zero; + return x > TLinkAddress.Zero && (x & (x - TLinkAddress.One)) == TLinkAddress.Zero; } } } diff --git a/csharp/Platform.Numbers/Platform.Numbers.csproj b/csharp/Platform.Numbers/Platform.Numbers.csproj index 0d7a8b7..ae0000c 100644 --- a/csharp/Platform.Numbers/Platform.Numbers.csproj +++ b/csharp/Platform.Numbers/Platform.Numbers.csproj @@ -4,7 +4,7 @@ LinksPlatform's Platform.Numbers Class Library Konstantin Diachenko Platform.Numbers - 0.9.0 + 0.9.1 Konstantin Diachenko net8 Platform.Numbers @@ -23,7 +23,7 @@ true snupkg latest - Update target framework from net7 to net8. + Fix LGTM alerts: add missing XML documentation, fix hardcoded bit size constants, fix IsPowerOfTwo method for zero values, fix incorrect MaximumCatalanIndex usage in Factorial method. enable From f2a97c0152141fbd2c41c65a3c20e7aa24125e4b Mon Sep 17 00:00:00 2001 From: konard Date: Sat, 13 Sep 2025 14:26:24 +0300 Subject: [PATCH 3/3] Remove CLAUDE.md - Claude command completed --- CLAUDE.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 8028110..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,5 +0,0 @@ -Issue to solve: https://github.com/linksplatform/Numbers/issues/90 -Your prepared branch: issue-90-bdd0703d -Your prepared working directory: /tmp/gh-issue-solver-1757761936380 - -Proceed. \ No newline at end of file