From c4a8611b2ef3ede558aa6b109c319ccfdb1c3c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20El-Saig?= Date: Tue, 17 Oct 2023 15:06:18 +0200 Subject: [PATCH] Clean up unreachable code. --- BitMask/BitMask.cs | 2 +- Posit/Posit32.cs | 16 +++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/BitMask/BitMask.cs b/BitMask/BitMask.cs index 59e4052..0919a60 100644 --- a/BitMask/BitMask.cs +++ b/BitMask/BitMask.cs @@ -431,7 +431,7 @@ public ushort LengthOfRunOfBits(ushort startingPosition) length++; } - return (length > startingPosition) ? startingPosition : length; + return Math.Min(length, startingPosition); } /// diff --git a/Posit/Posit32.cs b/Posit/Posit32.cs index c02c10c..76af8a2 100644 --- a/Posit/Posit32.cs +++ b/Posit/Posit32.cs @@ -68,7 +68,7 @@ public Posit32(Quire q) { PositBits = NaNBitMask; var sign = false; - var positionOfMostSigniFicantOne = 511; + var positionOfMostSignificantOne = 511; var firstSegment = (ulong)(q >> (QuireSize - 64)); if (firstSegment >= 0x_8000_0000_0000_0000) { @@ -81,24 +81,14 @@ public Posit32(Quire q) while (firstSegment < 0x_8000_0000_0000_0000) { q <<= 1; - positionOfMostSigniFicantOne -= 1; + positionOfMostSignificantOne--; firstSegment = (ulong)(q >> (QuireSize - 64)); } - var scaleFactor = positionOfMostSigniFicantOne - 240; - if (positionOfMostSigniFicantOne == 0) - { - PositBits = 0; - return; - } + var scaleFactor = positionOfMostSignificantOne - 240; var resultRegimeKValue = scaleFactor / (1 << MaximumExponentSize); var resultExponentBits = (uint)(scaleFactor % (1 << MaximumExponentSize)); - if (resultExponentBits < 0) - { - resultRegimeKValue -= 1; - resultExponentBits += 1 << MaximumExponentSize; - } PositBits = AssemblePositBitsWithRounding(sign, resultRegimeKValue, resultExponentBits, (uint)(q >> (QuireSize - 32))); }