Skip to content

Commit

Permalink
Clean up unreachable code.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Oct 17, 2023
1 parent cbe8751 commit c4a8611
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion BitMask/BitMask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ public ushort LengthOfRunOfBits(ushort startingPosition)
length++;
}

return (length > startingPosition) ? startingPosition : length;
return Math.Min(length, startingPosition);
}

/// <summary>
Expand Down
16 changes: 3 additions & 13 deletions Posit/Posit32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)));
}
Expand Down

0 comments on commit c4a8611

Please sign in to comment.