Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libraries/System.Private.CoreLib/src/System/Half.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1568,7 +1568,7 @@ public static int ILogB(Half x)
}

Debug.Assert(IsSubnormal(x));
return MinExponent - (BitOperations.TrailingZeroCount(x.TrailingSignificand) - BiasedExponentLength);
return MinExponent - (BitOperations.LeadingZeroCount(x.TrailingSignificand) - BiasedExponentLength);
}

return x.Exponent;
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Private.CoreLib/src/System/Math.cs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ public static int ILogB(double x)
}

Debug.Assert(double.IsSubnormal(x));
return double.MinExponent - (BitOperations.TrailingZeroCount(x.TrailingSignificand) - double.BiasedExponentLength);
return double.MinExponent - (BitOperations.LeadingZeroCount(x.TrailingSignificand) - double.BiasedExponentLength);
}

return x.Exponent;
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Private.CoreLib/src/System/MathF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public static int ILogB(float x)
}

Debug.Assert(float.IsSubnormal(x));
return float.MinExponent - (BitOperations.TrailingZeroCount(x.TrailingSignificand) - float.BiasedExponentLength);
return float.MinExponent - (BitOperations.LeadingZeroCount(x.TrailingSignificand) - float.BiasedExponentLength);
}

return x.Exponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2287,6 +2287,7 @@ public static void FusedMultiplyAdd(double x, double y, double z, double expecte
[InlineData( 0.561760, -1)]
[InlineData( 0.774152, -1)]
[InlineData( -0.678764, -1)]
[InlineData( 1e-308, -1024)]
public static void ILogB(double value, int expectedResult)
{
Assert.Equal(expectedResult, Math.ILogB(value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ public static void IEEERemainder()
[InlineData(0.561760f, -1)]
[InlineData(0.774152f, -1)]
[InlineData(-0.678764f, -1)]
[InlineData(1e-44f, -147)]
public static void ILogB(float value, int expectedResult)
{
Assert.Equal(expectedResult, MathF.ILogB(value));
Expand Down
Loading