diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastCache.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastCache.cs index 7653749d5d5f28..22f9e762d473b5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastCache.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastCache.cs @@ -250,7 +250,7 @@ internal static CastResult TryGet(int[] table, nuint source, nuint target) TableMask(ref tableData) = size - 1; // Fibonacci hash reduces the value into desired range by shifting right by the number of leading zeroes in 'size-1' - byte shift = (byte)BitOperations.LeadingZeroCount(size - 1); + byte shift = (byte)BitOperations.LeadingZeroCount((nuint)(size - 1)); HashShift(ref tableData) = shift; return table; diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/GenericCache.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/GenericCache.cs index 712f5ed924645c..31bd1ff9b50fe6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/GenericCache.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/GenericCache.cs @@ -230,7 +230,7 @@ internal bool TryGet(TKey key, out TValue? value) ref Entry tableData = ref TableData(table); // Fibonacci hash reduces the value into desired range by shifting right by the number of leading zeroes in 'size-1' - byte shift = (byte)BitOperations.LeadingZeroCount(size - 1); + byte shift = (byte)BitOperations.LeadingZeroCount((nuint)(size - 1)); HashShift(table) = shift; return table;