521 references to BitOperations
GenerateDocumentationAndConfigFiles (2)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
1269return BitOperations.Log2(value);
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (1)
175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
http2cat (2)
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (1)
319switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
src\Shared\runtime\Http2\Hpack\IntegerDecoder.cs (1)
71if (BitOperations.LeadingZeroCount((uint)b) <= _m)
IIS.FunctionalTests (2)
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (1)
319switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
src\Shared\runtime\Http2\Hpack\IntegerDecoder.cs (1)
71if (BitOperations.LeadingZeroCount((uint)b) <= _m)
IIS.LongTests (2)
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (1)
319switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
src\Shared\runtime\Http2\Hpack\IntegerDecoder.cs (1)
71if (BitOperations.LeadingZeroCount((uint)b) <= _m)
IIS.NewHandler.FunctionalTests (2)
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (1)
319switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
src\Shared\runtime\Http2\Hpack\IntegerDecoder.cs (1)
71if (BitOperations.LeadingZeroCount((uint)b) <= _m)
IISExpress.FunctionalTests (2)
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (1)
319switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
src\Shared\runtime\Http2\Hpack\IntegerDecoder.cs (1)
71if (BitOperations.LeadingZeroCount((uint)b) <= _m)
Microsoft.AspNetCore.Antiforgery (1)
src\Shared\Encoding\Int7BitEncodingUtils.cs (1)
17return ((31 - System.Numerics.BitOperations.LeadingZeroCount(value | 1)) / 7) + 1;
Microsoft.AspNetCore.DataProtection (1)
src\Shared\Encoding\Int7BitEncodingUtils.cs (1)
17return ((31 - System.Numerics.BitOperations.LeadingZeroCount(value | 1)) / 7) + 1;
Microsoft.AspNetCore.HttpLogging (17)
W3CLoggingMiddleware.cs (17)
25internal static readonly int _dateIndex = BitOperations.Log2((int)W3CLoggingFields.Date); 26internal static readonly int _timeIndex = BitOperations.Log2((int)W3CLoggingFields.Time); 27internal static readonly int _clientIpIndex = BitOperations.Log2((int)W3CLoggingFields.ClientIpAddress); 28internal static readonly int _userNameIndex = BitOperations.Log2((int)W3CLoggingFields.UserName); 29internal static readonly int _serverNameIndex = BitOperations.Log2((int)W3CLoggingFields.ServerName); 30internal static readonly int _serverIpIndex = BitOperations.Log2((int)W3CLoggingFields.ServerIpAddress); 31internal static readonly int _serverPortIndex = BitOperations.Log2((int)W3CLoggingFields.ServerPort); 32internal static readonly int _methodIndex = BitOperations.Log2((int)W3CLoggingFields.Method); 33internal static readonly int _uriStemIndex = BitOperations.Log2((int)W3CLoggingFields.UriStem); 34internal static readonly int _uriQueryIndex = BitOperations.Log2((int)W3CLoggingFields.UriQuery); 35internal static readonly int _protocolStatusIndex = BitOperations.Log2((int)W3CLoggingFields.ProtocolStatus); 36internal static readonly int _timeTakenIndex = BitOperations.Log2((int)W3CLoggingFields.TimeTaken); 37internal static readonly int _protocolVersionIndex = BitOperations.Log2((int)W3CLoggingFields.ProtocolVersion); 38internal static readonly int _hostIndex = BitOperations.Log2((int)W3CLoggingFields.Host); 39internal static readonly int _userAgentIndex = BitOperations.Log2((int)W3CLoggingFields.UserAgent); 40internal static readonly int _cookieIndex = BitOperations.Log2((int)W3CLoggingFields.Cookie); 41internal static readonly int _refererIndex = BitOperations.Log2((int)W3CLoggingFields.Referer);
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (2)
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (1)
319switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
src\Shared\runtime\Http2\Hpack\IntegerDecoder.cs (1)
71if (BitOperations.LeadingZeroCount((uint)b) <= _m)
Microsoft.AspNetCore.Server.Kestrel.Core (22)
Internal\Http\HttpHeaders.Generated.cs (17)
2586return (_contentLength.HasValue ? 1 : 0 ) + BitOperations.PopCount((ulong)_bits) + (MaybeUnknown?.Count ?? 0); 8664_next = BitOperations.TrailingZeroCount(_currentBits); 8678? BitOperations.TrailingZeroCount(bits) 10872return (_contentLength.HasValue ? 1 : 0 ) + BitOperations.PopCount((ulong)_bits) + (MaybeUnknown?.Count ?? 0); 14053if(BitOperations.PopCount((ulong)tempBits) > 12) 14813var next = BitOperations.TrailingZeroCount(tempBits); 14840next = BitOperations.TrailingZeroCount(tempBits); 14866next = BitOperations.TrailingZeroCount(tempBits); 14885next = BitOperations.TrailingZeroCount(tempBits); 14967next = BitOperations.TrailingZeroCount(tempBits); 15112next = BitOperations.TrailingZeroCount(tempBits); 15192next = BitOperations.TrailingZeroCount(tempBits); 15500_next = BitOperations.TrailingZeroCount(_currentBits); 15514? BitOperations.TrailingZeroCount(bits) 17169return (_contentLength.HasValue ? 1 : 0 ) + BitOperations.PopCount((ulong)_bits) + (MaybeUnknown?.Count ?? 0); 17486if(BitOperations.PopCount((ulong)tempBits) > 12) 17621_next = BitOperations.TrailingZeroCount(_currentBits);
Internal\Http\HttpResponseTrailers.cs (2)
63_next = _currentBits != 0 ? BitOperations.TrailingZeroCount(_currentBits) : -1; 85_next = _currentBits != 0 ? BitOperations.TrailingZeroCount(_currentBits) : -1;
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (1)
319switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
src\Shared\runtime\Http2\Hpack\IntegerDecoder.cs (1)
71if (BitOperations.LeadingZeroCount((uint)b) <= _m)
src\Shared\runtime\Http3\QPack\QPackDecoder.cs (1)
434switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
Microsoft.AspNetCore.Shared.Tests (4)
src\Shared\Encoding\Int7BitEncodingUtils.cs (1)
17return ((31 - System.Numerics.BitOperations.LeadingZeroCount(value | 1)) / 7) + 1;
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (1)
319switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
src\Shared\runtime\Http2\Hpack\IntegerDecoder.cs (1)
71if (BitOperations.LeadingZeroCount((uint)b) <= _m)
src\Shared\runtime\Http3\QPack\QPackDecoder.cs (1)
434switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
Microsoft.CodeAnalysis (2)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
1269return BitOperations.Log2(value);
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (1)
175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
Microsoft.CodeAnalysis.Collections.Package (2)
Internal\ArraySortHelper.cs (1)
1269return BitOperations.Log2(value);
Internal\SegmentedArrayHelper.cs (1)
175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
Microsoft.CodeAnalysis.InteractiveHost (2)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
1269return BitOperations.Log2(value);
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (1)
175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
Microsoft.CodeAnalysis.Threading.Package (2)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
1269return BitOperations.Log2(value);
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (1)
175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
Microsoft.CodeAnalysis.Workspaces (2)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
1269return BitOperations.Log2(value);
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (1)
175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (2)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
1269return BitOperations.Log2(value);
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (1)
175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));
Microsoft.NET.StringTools (1)
InternableString.cs (1)
391return System.Numerics.BitOperations.RotateLeft(value, offset);
System.Collections (1)
System\Collections\Generic\SortedSet.cs (1)
2011private static int Log2(int value) => BitOperations.Log2((uint)value);
System.Collections.Immutable (22)
System\Collections\Frozen\String\Hashing.cs (22)
35hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ src[0]; 39hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ src[0]; 40hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ src[1]; 44hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ src[0]; 45hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ src[1]; 46hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ src[2]; 50hash1 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ ((uint*)src)[0]; 51hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ ((uint*)src)[1]; 61hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ ptrUInt32[0]; 62hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ ptrUInt32[1]; 70hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ *ptrChar++; 99hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ (src[0] | LowercaseChar); 103hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ (src[0] | LowercaseChar); 104hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (src[1] | LowercaseChar); 108hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ (src[0] | LowercaseChar); 109hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (src[1] | LowercaseChar); 110hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (src[2] | LowercaseChar); 114hash1 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ (((uint*)src)[0] | LowercaseUInt32); 115hash2 = (BitOperations.RotateLeft(Hash1Start, 5) + Hash1Start) ^ (((uint*)src)[1] | LowercaseUInt32); 125hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ (ptrUInt32[0] | LowercaseUInt32); 126hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (ptrUInt32[1] | LowercaseUInt32); 134hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (*ptrChar | LowercaseUInt32);
System.Collections.Specialized (2)
System\Collections\Specialized\BitVector32.cs (2)
141short offset = (short)(priorOffset + BitOperations.PopCount((uint)(ushort)priorMask)); 147short mask = (short)(BitOperations.RoundUpToPowerOf2((uint)(ushort)maxValue + 1) - 1);
System.Diagnostics.DiagnosticSource (1)
System\Diagnostics\Metrics\Base2ExponentialHistogramAggregator.cs (1)
273return BitOperations.LeadingZeroCount((ulong)value);
System.IO.Hashing (18)
System\IO\Hashing\XxHash128.cs (1)
266uint combinedh = BitOperations.RotateLeft(BinaryPrimitives.ReverseEndianness(combinedl), 13);
System\IO\Hashing\XxHash32.State.cs (7)
54BitOperations.RotateLeft(_acc1, 1) + 55BitOperations.RotateLeft(_acc2, 7) + 56BitOperations.RotateLeft(_acc3, 12) + 57BitOperations.RotateLeft(_acc4, 18); 63acc = BitOperations.RotateLeft(acc, 13); 79acc = BitOperations.RotateLeft(acc, 17); 89acc = BitOperations.RotateLeft(acc, 11);
System\IO\Hashing\XxHash64.State.cs (8)
73BitOperations.RotateLeft(_acc1, 1) + 74BitOperations.RotateLeft(_acc2, 7) + 75BitOperations.RotateLeft(_acc3, 12) + 76BitOperations.RotateLeft(_acc4, 18); 94acc = BitOperations.RotateLeft(acc, 31); 114acc = BitOperations.RotateLeft(acc, 27); 126acc = BitOperations.RotateLeft(acc, 23); 137acc = BitOperations.RotateLeft(acc, 11);
System\IO\Hashing\XxHashShared.cs (2)
195hash ^= BitOperations.RotateLeft(hash, 49) ^ BitOperations.RotateLeft(hash, 24);
System.Linq.Expressions (1)
System\Dynamic\Utils\CacheDict.cs (1)
44int alignedSize = (int)BitOperations.RoundUpToPowerOf2((uint)size);
System.Net.Http (3)
src\libraries\Common\src\System\Net\Http\aspnetcore\Http2\Hpack\HPackDecoder.cs (1)
319switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
src\libraries\Common\src\System\Net\Http\aspnetcore\Http2\Hpack\IntegerDecoder.cs (1)
71if (BitOperations.LeadingZeroCount((uint)b) <= _m)
src\libraries\Common\src\System\Net\Http\aspnetcore\Http3\QPack\QPackDecoder.cs (1)
434switch (BitOperations.LeadingZeroCount(b) - 24) // byte 'b' is extended to uint, so will have 24 extra 0s.
System.Net.Security (3)
src\libraries\Common\src\System\Net\Security\MD4.cs (3)
158a = BitOperations.RotateLeft(a, s); 164a = BitOperations.RotateLeft(a, s); 170a = BitOperations.RotateLeft(a, s);
System.Net.WebSockets (2)
System\Net\WebSockets\ManagedWebSocket.cs (2)
1672(int)BitOperations.RotateRight((uint)mask, maskIndex * 8) : 1673(int)BitOperations.RotateLeft((uint)mask, maskIndex * 8);
System.Numerics.Tensors (9)
System\Numerics\Tensors\netcore\TensorPrimitives.HammingDistance.cs (6)
91count += BitOperations.PopCount((~Vector512.Equals(xVec, yVec)).ExtractMostSignificantBits()); 107count += BitOperations.PopCount((~Vector512.Equals(xVec, yVec)).ExtractMostSignificantBits()); 123count += BitOperations.PopCount((~Vector256.Equals(xVec, yVec)).ExtractMostSignificantBits()); 139count += BitOperations.PopCount((~Vector256.Equals(xVec, yVec)).ExtractMostSignificantBits()); 156count += BitOperations.PopCount((~Vector128.Equals(xVec, yVec)).ExtractMostSignificantBits()); 172count += BitOperations.PopCount((~Vector128.Equals(xVec, yVec)).ExtractMostSignificantBits());
System\Numerics\Tensors\netcore\TensorPrimitives.IndexOfMax.cs (3)
423BitOperations.TrailingZeroCount(mask.ExtractMostSignificantBits()); 426BitOperations.TrailingZeroCount(mask.ExtractMostSignificantBits()); 429BitOperations.TrailingZeroCount(mask.ExtractMostSignificantBits());
System.Private.CoreLib (327)
src\libraries\Common\src\Internal\VersionResilientHashCode.cs (2)
171return (int)BitOperations.RotateLeft((uint)value, bitCount); 183return (BitOperations.RotateLeft((hash + queuedValue * 3266489917U/*Prime3*/), 17)) * 668265263U/*Prime4*/;
src\libraries\Common\src\System\Sha1ForNonSecretPurposes.cs (9)
180w[i] = BitOperations.RotateLeft(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1); 193uint temp = BitOperations.RotateLeft(a, 5) + f + e + k + w[i]; e = d; d = c; c = BitOperations.RotateLeft(b, 30); b = a; a = temp; 200uint temp = BitOperations.RotateLeft(a, 5) + f + e + k + w[i]; e = d; d = c; c = BitOperations.RotateLeft(b, 30); b = a; a = temp; 207uint temp = BitOperations.RotateLeft(a, 5) + f + e + k + w[i]; e = d; d = c; c = BitOperations.RotateLeft(b, 30); b = a; a = temp; 214uint temp = BitOperations.RotateLeft(a, 5) + f + e + k + w[i]; e = d; d = c; c = BitOperations.RotateLeft(b, 30); b = a; a = temp;
src\libraries\System.Private.CoreLib\src\System\Array.cs (2)
2704IntroSort(left, length + left - 1, 2 * (BitOperations.Log2((uint)length) + 1)); 2917IntroSort(left, length + left - 1, 2 * (BitOperations.Log2((uint)length) + 1));
src\libraries\System.Private.CoreLib\src\System\Buffers\Binary\BinaryPrimitives.ReverseEndianness.cs (2)
150return BitOperations.RotateRight(value & 0x00FF00FFu, 8) // xx zz 151+ BitOperations.RotateLeft(value & 0xFF00FF00u, 8); // ww yy
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\FormattingHelpers.CountDigits.cs (1)
112return (BitOperations.Log2(value) >> 2) + 1;
src\libraries\System.Private.CoreLib\src\System\Buffers\Utilities.cs (1)
20return BitOperations.Log2((uint)bufferSize - 1 | 15) - 3;
src\libraries\System.Private.CoreLib\src\System\Byte.cs (5)
282public static byte LeadingZeroCount(byte value) => (byte)(BitOperations.LeadingZeroCount(value) - 24); 288public static byte PopCount(byte value) => (byte)BitOperations.PopCount(value); 297public static byte TrailingZeroCount(byte value) => (byte)(BitOperations.TrailingZeroCount(value << 24) - 24); 415public static bool IsPow2(byte value) => BitOperations.IsPow2((uint)value); 418public static byte Log2(byte value) => (byte)BitOperations.Log2(value);
src\libraries\System.Private.CoreLib\src\System\Char.cs (3)
1215static char IBinaryInteger<char>.LeadingZeroCount(char value) => (char)(BitOperations.LeadingZeroCount(value) - 16); 1221static char IBinaryInteger<char>.PopCount(char value) => (char)BitOperations.PopCount(value); 1230static char IBinaryInteger<char>.TrailingZeroCount(char value) => (char)(BitOperations.TrailingZeroCount(value << 16) - 16);
src\libraries\System.Private.CoreLib\src\System\Collections\Concurrent\ConcurrentQueue.cs (1)
97length = (int)Math.Min(BitOperations.RoundUpToPowerOf2((uint)count), MaxSegmentLength);
src\libraries\System.Private.CoreLib\src\System\Collections\Concurrent\ConcurrentQueueSegment.cs (1)
49Debug.Assert(BitOperations.IsPow2(boundedLength), $"Must be a power of 2, got {boundedLength}");
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ArraySortHelper.cs (6)
127IntroSort(keys, 2 * (BitOperations.Log2((uint)keys.Length) + 1), comparer); 306IntroSort(keys, 2 * (BitOperations.Log2((uint)keys.Length) + 1)); 673IntroSort(keys, values, 2 * (BitOperations.Log2((uint)keys.Length) + 1), comparer); 858IntroSort(keys, values, 2 * (BitOperations.Log2((uint)keys.Length) + 1)); 1196IntroSort(keys, 2 * (BitOperations.Log2((uint)keys.Length) + 1), comparer); 1411IntroSort(keys, values, 2 * (BitOperations.Log2((uint)keys.Length) + 1), comparer);
src\libraries\System.Private.CoreLib\src\System\Decimal.DecCalc.cs (3)
626newScale -= BitOperations.LeadingZeroCount(result[hiRes]); 2038curScale = BitOperations.LeadingZeroCount(tmp); 2311int shift = BitOperations.LeadingZeroCount(tmp);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\ManifestBuilder.cs (1)
456if (isbitmap && !BitOperations.IsPow2(hexValue))
src\libraries\System.Private.CoreLib\src\System\Globalization\Ordinal.cs (4)
515mask = BitOperations.ResetLowestSetBit(BitOperations.ResetLowestSetBit(mask)); 581mask = BitOperations.ResetLowestSetBit(BitOperations.ResetLowestSetBit(mask));
src\libraries\System.Private.CoreLib\src\System\Half.cs (1)
1105int shiftDist = BitOperations.LeadingZeroCount(sig) - 16 - 5;
src\libraries\System.Private.CoreLib\src\System\HashCode.cs (6)
271return BitOperations.RotateLeft(hash + input * Prime2, 13) * Prime1; 277return BitOperations.RotateLeft(hash + queuedValue * Prime3, 17) * Prime4; 283return BitOperations.RotateLeft(v1, 1) + BitOperations.RotateLeft(v2, 7) + BitOperations.RotateLeft(v3, 12) + BitOperations.RotateLeft(v4, 18);
src\libraries\System.Private.CoreLib\src\System\Int128.cs (2)
724return 64 + BitOperations.LeadingZeroCount(value._lower); 726return BitOperations.LeadingZeroCount(value._upper);
src\libraries\System.Private.CoreLib\src\System\Int16.cs (5)
285public static short LeadingZeroCount(short value) => (short)(BitOperations.LeadingZeroCount((ushort)value) - 16); 298public static short PopCount(short value) => (short)BitOperations.PopCount((ushort)value); 307public static short TrailingZeroCount(short value) => (byte)(BitOperations.TrailingZeroCount(value << 16) - 16); 509public static bool IsPow2(short value) => BitOperations.IsPow2(value); 518return (short)BitOperations.Log2((ushort)value);
src\libraries\System.Private.CoreLib\src\System\Int32.cs (7)
301public static int LeadingZeroCount(int value) => BitOperations.LeadingZeroCount((uint)value); 316public static int PopCount(int value) => BitOperations.PopCount((uint)value); 320public static int RotateLeft(int value, int rotateAmount) => (int)BitOperations.RotateLeft((uint)value, rotateAmount); 324public static int RotateRight(int value, int rotateAmount) => (int)BitOperations.RotateRight((uint)value, rotateAmount); 328public static int TrailingZeroCount(int value) => BitOperations.TrailingZeroCount(value); 549public static bool IsPow2(int value) => BitOperations.IsPow2(value); 560return BitOperations.Log2((uint)value);
src\libraries\System.Private.CoreLib\src\System\Int64.cs (9)
298public static long LeadingZeroCount(long value) => BitOperations.LeadingZeroCount((ulong)value); 313public static long PopCount(long value) => BitOperations.PopCount((ulong)value); 317public static long RotateLeft(long value, int rotateAmount) => (long)BitOperations.RotateLeft((ulong)value, rotateAmount); 321public static long RotateRight(long value, int rotateAmount) => (long)BitOperations.RotateRight((ulong)value, rotateAmount); 325public static long TrailingZeroCount(long value) => BitOperations.TrailingZeroCount(value); 501return (sizeof(long) * 8) - BitOperations.LeadingZeroCount((ulong)(value)); 505return (sizeof(long) * 8) + 1 - BitOperations.LeadingZeroCount((ulong)(~value)); 546public static bool IsPow2(long value) => BitOperations.IsPow2(value); 557return BitOperations.Log2((ulong)value);
src\libraries\System.Private.CoreLib\src\System\IntPtr.cs (9)
321public static nint LeadingZeroCount(nint value) => BitOperations.LeadingZeroCount((nuint)value); 336public static nint PopCount(nint value) => BitOperations.PopCount((nuint)value); 340public static nint RotateLeft(nint value, int rotateAmount) => (nint)BitOperations.RotateLeft((nuint)value, rotateAmount); 344public static nint RotateRight(nint value, int rotateAmount) => (nint)BitOperations.RotateRight((nuint)value, rotateAmount); 348public static nint TrailingZeroCount(nint value) => BitOperations.TrailingZeroCount(value); 524return (sizeof(nint_t) * 8) - BitOperations.LeadingZeroCount((nuint)value); 528return (sizeof(nint_t) * 8) + 1 - BitOperations.LeadingZeroCount((nuint)(~value)); 569public static bool IsPow2(nint value) => BitOperations.IsPow2(value); 580return BitOperations.Log2((nuint)value);
src\libraries\System.Private.CoreLib\src\System\Marvin.cs (1)
10using static System.Numerics.BitOperations;
src\libraries\System.Private.CoreLib\src\System\Math.cs (1)
898return double.MinExponent - (BitOperations.LeadingZeroCount(x.TrailingSignificand) - double.BiasedExponentLength);
src\libraries\System.Private.CoreLib\src\System\MathF.cs (1)
213return float.MinExponent - (BitOperations.LeadingZeroCount(x.TrailingSignificand) - float.BiasedExponentLength);
src\libraries\System.Private.CoreLib\src\System\Number.BigInteger.cs (3)
426return 32 - BitOperations.LeadingZeroCount(value); 431return 64 - BitOperations.LeadingZeroCount(value); 527int shiftLeft = BitOperations.LeadingZeroCount(divHi);
src\libraries\System.Private.CoreLib\src\System\Number.DiyFp.cs (1)
93int lzcnt = BitOperations.LeadingZeroCount(f);
src\libraries\System.Private.CoreLib\src\System\Number.Dragon4.cs (2)
35mantissaHighBitIdx = (uint)BitOperations.Log2(mantissa); 287int hiBlockLog2 = BitOperations.Log2(hiBlock);
src\libraries\System.Private.CoreLib\src\System\Number.Formatting.cs (2)
596int lz = BitOperations.LeadingZeroCount(fraction) - (63 - mantissaBits); 707int trailingZeroBits = BitOperations.TrailingZeroCount(nibbleAligned);
src\libraries\System.Private.CoreLib\src\System\Number.NumberToFloatingPointBits.cs (1)
1298int lz = BitOperations.LeadingZeroCount(w);
src\libraries\System.Private.CoreLib\src\System\Number.Parsing.cs (1)
1246int lz = BitOperations.LeadingZeroCount(significand);
src\libraries\System.Private.CoreLib\src\System\Random.CompatImpl.cs (2)
72int bits = BitOperations.Log2Ceiling(exclusiveRange); 195int bits = BitOperations.Log2Ceiling(exclusiveRange);
src\libraries\System.Private.CoreLib\src\System\Random.cs (2)
215if (BitOperations.IsPow2(choices.Length)) 247int mask = (int)BitOperations.RoundUpToPowerOf2((uint)choices.Length) - 1;
src\libraries\System.Private.CoreLib\src\System\Random.Xoshiro256StarStarImpl.cs (6)
57ulong result = BitOperations.RotateLeft(s1 * 5, 7) * 9; 66s3 = BitOperations.RotateLeft(s3, 45); 142MemoryMarshal.Write(buffer, BitOperations.RotateLeft(s1 * 5, 7) * 9); 151s3 = BitOperations.RotateLeft(s3, 45); 158ulong next = BitOperations.RotateLeft(s1 * 5, 7) * 9; 173s3 = BitOperations.RotateLeft(s3, 45);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\CastCache.cs (4)
39Debug.Assert(BitOperations.PopCount((uint)initialCacheSize) == 1 && initialCacheSize > 1); 40Debug.Assert(BitOperations.PopCount((uint)maxCacheSize) == 1 && maxCacheSize >= initialCacheSize); 95nuint hash = BitOperations.RotateLeft(source, (nuint.Size * 8) / 2) ^ target; 253byte shift = (byte)BitOperations.LeadingZeroCount((nuint)(size - 1));
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\ConditionalWeakTable.cs (3)
570Debug.Assert(BitOperations.IsPow2(InitialCapacity)); 593Debug.Assert(BitOperations.IsPow2(buckets.Length)); 798Debug.Assert(BitOperations.IsPow2(newSize));
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\GenericCache.cs (3)
77Debug.Assert(BitOperations.PopCount((uint)initialCacheSize) == 1 && initialCacheSize > 1); 78Debug.Assert(BitOperations.PopCount((uint)maxCacheSize) == 1 && maxCacheSize >= initialCacheSize); 234byte shift = (byte)BitOperations.LeadingZeroCount((nuint)(size - 1));
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\NativeMemory.Unix.cs (2)
27if (!BitOperations.IsPow2(alignment)) 90if (!BitOperations.IsPow2(alignment))
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector128.cs (6)
4556return AdvSimdFixupBitCount<T>(BitOperations.PopCount(AdvSimdExtractBitMask(vector))); 4560return BitOperations.PopCount(vector.ExtractMostSignificantBits()); 4577int result = AdvSimdFixupBitCount<T>(BitOperations.TrailingZeroCount(AdvSimdExtractBitMask(vector))); 4582int result = BitOperations.TrailingZeroCount(vector.ExtractMostSignificantBits()); 4592return (Vector128<T>.Count - 1) - AdvSimdFixupBitCount<T>(BitOperations.LeadingZeroCount(AdvSimdExtractBitMask(vector))); 4596return 31 - BitOperations.LeadingZeroCount(vector.ExtractMostSignificantBits());
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector256.cs (3)
4456return BitOperations.PopCount(vector.ExtractMostSignificantBits()); 4478int result = BitOperations.TrailingZeroCount(vector.ExtractMostSignificantBits()); 4500return 31 - BitOperations.LeadingZeroCount(vector.ExtractMostSignificantBits());
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector512.cs (3)
4426return BitOperations.PopCount(vector.ExtractMostSignificantBits()); 4448int result = BitOperations.TrailingZeroCount(vector.ExtractMostSignificantBits()); 4470return 63 - BitOperations.LeadingZeroCount(vector.ExtractMostSignificantBits());
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector64.cs (6)
4452return AdvSimdFixupBitCount<T>(BitOperations.PopCount(AdvSimdExtractBitMask(vector))); 4456return BitOperations.PopCount(vector.ExtractMostSignificantBits()); 4473int result = AdvSimdFixupBitCount<T>(BitOperations.TrailingZeroCount(AdvSimdExtractBitMask(vector))); 4478int result = BitOperations.TrailingZeroCount(vector.ExtractMostSignificantBits()); 4488return (Vector64<T>.Count - 1) - AdvSimdFixupBitCount<T>(BitOperations.LeadingZeroCount(AdvSimdExtractBitMask(vector))); 4492return 31 - BitOperations.LeadingZeroCount(vector.ExtractMostSignificantBits());
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\X86\X86Base.cs (4)
41/// <para>Its functionality is exposed in the public <see cref="Numerics.BitOperations" /> class.</para> 52/// <para>Its functionality is exposed in the public <see cref="Numerics.BitOperations" /> class.</para> 78/// <para>Its functionality is exposed in the public <see cref="Numerics.BitOperations" /> class.</para> 89/// <para>Its functionality is exposed in the public <see cref="Numerics.BitOperations" /> class.</para>
src\libraries\System.Private.CoreLib\src\System\SByte.cs (5)
288public static sbyte LeadingZeroCount(sbyte value) => (sbyte)(BitOperations.LeadingZeroCount((byte)value) - 24); 301public static sbyte PopCount(sbyte value) => (sbyte)BitOperations.PopCount((byte)value); 310public static sbyte TrailingZeroCount(sbyte value) => (sbyte)(BitOperations.TrailingZeroCount(value << 24) - 24); 472public static bool IsPow2(sbyte value) => BitOperations.IsPow2(value); 481return (sbyte)BitOperations.Log2((byte)value);
src\libraries\System.Private.CoreLib\src\System\SearchValues\ProbabilisticMap.cs (16)
785index = BitOperations.TrailingZeroCount(mask); 792mask = BitOperations.ResetLowestSetBit(mask); 806index = BitOperations.TrailingZeroCount(mask); 820mask = BitOperations.ResetLowestSetBit(mask); 834index = BitOperations.TrailingZeroCount(mask); 841mask = BitOperations.ResetLowestSetBit(mask); 855index = BitOperations.TrailingZeroCount(mask); 869mask = BitOperations.ResetLowestSetBit(mask); 883index = 31 - BitOperations.LeadingZeroCount(mask); 891mask = BitOperations.FlipBit(mask, index); 905index = 31 - BitOperations.LeadingZeroCount(mask); 908mask = BitOperations.FlipBit(mask, index); 934index = 63 - BitOperations.LeadingZeroCount(mask); 942mask = BitOperations.FlipBit(mask, index); 956index = 63 - BitOperations.LeadingZeroCount(mask); 959mask = BitOperations.FlipBit(mask, index);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\AsciiStringSearchValuesTeddyBase.cs (12)
543int matchOffset = BitOperations.TrailingZeroCount(resultMask); 558int candidateOffset = BitOperations.TrailingZeroCount(candidateMask); 570candidateMask = BitOperations.ResetLowestSetBit(candidateMask); 574resultMask = BitOperations.ResetLowestSetBit(resultMask); 591int matchOffset = BitOperations.TrailingZeroCount(resultMask); 603int candidateOffset = BitOperations.TrailingZeroCount(candidateMask); 615candidateMask = BitOperations.ResetLowestSetBit(candidateMask); 619resultMask = BitOperations.ResetLowestSetBit(resultMask); 636int matchOffset = BitOperations.TrailingZeroCount(resultMask); 648int candidateOffset = BitOperations.TrailingZeroCount(candidateMask); 660candidateMask = BitOperations.ResetLowestSetBit(candidateMask); 664resultMask = BitOperations.ResetLowestSetBit(resultMask);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\SingleStringSearchValuesPackedThreeChars.cs (4)
335int bitPos = BitOperations.TrailingZeroCount(mask); 347mask = BitOperations.ResetLowestSetBit(mask); 362int bitPos = BitOperations.TrailingZeroCount(mask); 374mask = BitOperations.ResetLowestSetBit(mask);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\SingleStringSearchValuesThreeChars.cs (6)
332int bitPos = BitOperations.TrailingZeroCount(mask); 345mask = BitOperations.ResetLowestSetBit(BitOperations.ResetLowestSetBit(mask)); 360int bitPos = BitOperations.TrailingZeroCount(mask); 373mask = BitOperations.ResetLowestSetBit(BitOperations.ResetLowestSetBit(mask));
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.Byte.cs (26)
113int bitPos = BitOperations.TrailingZeroCount(mask); 121mask = BitOperations.ResetLowestSetBit(mask); // Clear the lowest set bit 174int bitPos = BitOperations.TrailingZeroCount(mask); 182mask = BitOperations.ResetLowestSetBit(mask); // Clear the lowest set bit 235int bitPos = BitOperations.TrailingZeroCount(mask); 244mask = BitOperations.ResetLowestSetBit(mask); 325int highestSetBitIndex = 63 - BitOperations.LeadingZeroCount(mask); 334mask = BitOperations.FlipBit(mask, highestSetBitIndex); 372int highestSetBitIndex = 31 - BitOperations.LeadingZeroCount(mask); 381mask = BitOperations.FlipBit(mask, highestSetBitIndex); 421int highestSetBitIndex = 31 - BitOperations.LeadingZeroCount(mask); 430mask = BitOperations.FlipBit(mask, highestSetBitIndex); 543return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 565return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 585return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 604return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 623return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 656return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 677return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 696return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 728return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 1012offset += (uint)BitOperations.TrailingZeroCount(differences); 1053offset += (uint)BitOperations.TrailingZeroCount(differences); 1090offset += (uint)BitOperations.TrailingZeroCount(differences); 1247=> BitOperations.TrailingZeroCount(match) >> 3; 1251=> BitOperations.Log2(match) >> 3;
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.Char.cs (18)
118int bitPos = BitOperations.TrailingZeroCount(mask); 195mask = BitOperations.ResetLowestSetBit(BitOperations.ResetLowestSetBit(mask)); 257mask = BitOperations.ResetLowestSetBit(BitOperations.ResetLowestSetBit(mask)); 342int bitPos = 62 - BitOperations.LeadingZeroCount(mask); 392int bitPos = 30 - BitOperations.LeadingZeroCount(mask); 442int bitPos = 30 - BitOperations.LeadingZeroCount(mask); 612return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 639return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 670return (int)(offset + (uint)BitOperations.TrailingZeroCount(matches)); 693return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 716return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 756return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 781return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 804return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 843return (int)(offset + ((uint)BitOperations.TrailingZeroCount(matches) / sizeof(char))); 868=> BitOperations.TrailingZeroCount(match) >> 4;
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.Packed.cs (6)
1233int index = BitOperations.TrailingZeroCount(notEqualsElements); 1242int index = BitOperations.TrailingZeroCount(notEqualsElements); 1251int index = BitOperations.TrailingZeroCount(notEqualsElements); 1259int offsetInVector = BitOperations.TrailingZeroCount(notEqualsElements); 1274int offsetInVector = BitOperations.TrailingZeroCount(notEqualsElements); 1289int offsetInVector = BitOperations.TrailingZeroCount(notEqualsElements);
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.T.cs (13)
38if (!BitOperations.IsPow2(sizeof(T))) 3717int index = BitOperations.TrailingZeroCount(notEqualsElements); 3725int index = BitOperations.TrailingZeroCount(notEqualsElements); 3733int index = BitOperations.TrailingZeroCount(notEqualsElements); 3741int index = 31 - BitOperations.LeadingZeroCount(notEqualsElements); // 31 = 32 (bits in Int32) - 1 (indexing from zero) 3749int index = 31 - BitOperations.LeadingZeroCount(notEqualsElements); // 31 = 32 (bits in Int32) - 1 (indexing from zero) 3757int index = 63 - BitOperations.LeadingZeroCount(notEqualsElements); // 31 = 32 (bits in Int32) - 1 (indexing from zero) 4179count += BitOperations.PopCount(Vector512.Equals(Vector512.LoadUnsafe(ref current), targetVector).ExtractMostSignificantBits()); 4186count += BitOperations.PopCount(mask); 4194count += BitOperations.PopCount(Vector256.Equals(Vector256.LoadUnsafe(ref current), targetVector).ExtractMostSignificantBits()); 4201count += BitOperations.PopCount(mask); 4209count += BitOperations.PopCount(Vector128.Equals(Vector128.LoadUnsafe(ref current), targetVector).ExtractMostSignificantBits()); 4216count += BitOperations.PopCount(mask);
src\libraries\System.Private.CoreLib\src\System\String.Comparison.cs (21)
777hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ ptr[0]; 778hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ ptr[1]; 784hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ ptr[0]; 808hash1 = BitOperations.RotateLeft(hash1, 5) + hash1 ^ Unsafe.ReadUnaligned<uint>(ptr); 809hash2 = BitOperations.RotateLeft(hash2, 5) + hash2 ^ Unsafe.ReadUnaligned<uint>(ptr + 1); 816hash1 = BitOperations.RotateLeft(hash1, 5) + hash1 ^ Unsafe.ReadUnaligned<uint>(ptr); 823hash2 = BitOperations.RotateLeft(hash2, 5) + hash2 ^ p1; 827hash2 = BitOperations.RotateLeft(hash2, 5) + hash2 ^ Unsafe.ReadUnaligned<uint>(ptr); 837hash2 = BitOperations.RotateLeft(hash2, 5) + hash2 ^ p0; 877hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ (p0 | NormalizeToLowercase); 878hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (p1 | NormalizeToLowercase); 890hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (p0 | NormalizeToLowercase); 926hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ (p0 | NormalizeToLowercase); 927hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (p1 | NormalizeToLowercase); 946hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ (p0 | NormalizeToLowercase); 947hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (p1 | NormalizeToLowercase); 957hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (p0 | NormalizeToLowercase); 972hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (p0 | NormalizeToLowercase); 1009hash1 = (BitOperations.RotateLeft(hash1, 5) + hash1) ^ (ptr[0] | NormalizeToLowercase); 1010hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (ptr[1] | NormalizeToLowercase); 1016hash2 = (BitOperations.RotateLeft(hash2, 5) + hash2) ^ (ptr[0] | NormalizeToLowercase);
src\libraries\System.Private.CoreLib\src\System\String.Manipulation.cs (6)
2120uint bitPos = (uint)BitOperations.TrailingZeroCount(mask) / sizeof(char); 2122mask = BitOperations.ResetLowestSetBit(mask); 2149uint bitPos = (uint)BitOperations.TrailingZeroCount(mask) / sizeof(char); 2151mask = BitOperations.ResetLowestSetBit(mask); 2178uint bitPos = (uint)BitOperations.TrailingZeroCount(mask) / sizeof(char); 2180mask = BitOperations.ResetLowestSetBit(mask);
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.Utility.cs (7)
83int index = BitOperations.TrailingZeroCount(mask) >> 2; 605pBuffer += (uint)BitOperations.TrailingZeroCount(currentSseMask); 650pBuffer += (nuint)(BitOperations.TrailingZeroCount(candidateUInt64) >> 3); 1150pBuffer = (char*)((byte*)pBuffer + (uint)BitOperations.TrailingZeroCount(currentMask) - 1); 1163pBuffer += BitOperations.TrailingZeroCount(asciiCompareMask) >> 3; 1211pBuffer = (char*)((byte*)pBuffer + ((nuint)(BitOperations.TrailingZeroCount(candidateUInt64) >> 3) & ~(nuint)1)); 2195asciiData = BitOperations.RotateLeft(asciiData, 8);
src\libraries\System.Private.CoreLib\src\System\Text\Ascii.Utility.Helpers.cs (4)
53return (uint)BitOperations.TrailingZeroCount(value & UInt32HighBitsOnlyMask) >> 3; 69value = BitOperations.RotateLeft(value, 1); 74value = BitOperations.RotateLeft(value, 8); 79value = BitOperations.RotateLeft(value, 8);
src\libraries\System.Private.CoreLib\src\System\Text\Latin1Utility.cs (1)
430pBuffer = (char*)((byte*)pBuffer + (uint)BitOperations.TrailingZeroCount(currentMask) - 1);
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf16Utility.Validation.cs (2)
201popcnt = (uint)BitOperations.PopCount(mask); // on x64, perform zero-extension for free 234nint surrogatePairsCountNint = (nint)BitOperations.PopCount(maskLow);
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.Helpers.cs (1)
118tempA = BitOperations.RotateLeft(tempA, 16); // = [ 00xxxxxx 00000000 00000000 00000uuu ]
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.Transcoding.cs (1)
605toCheck = BitOperations.RotateRight(toCheck, 8);
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.Validation.cs (3)
140trailingZeroCount = (nuint)BitOperations.TrailingZeroCount(mask) >> 2; 158trailingZeroCount = (nuint)BitOperations.TrailingZeroCount(mask); 610thisDWord = BitOperations.RotateRight(thisDWord, 8);
src\libraries\System.Private.CoreLib\src\System\Threading\ThreadLocal.cs (1)
556uint newSize = BitOperations.RoundUpToPowerOf2((uint)minSize);
src\libraries\System.Private.CoreLib\src\System\UInt128.cs (3)
795return 64 + BitOperations.LeadingZeroCount(value._lower); 797return BitOperations.LeadingZeroCount(value._upper); 1241int shift = BitOperations.LeadingZeroCount(divHi);
src\libraries\System.Private.CoreLib\src\System\UInt16.cs (5)
279public static ushort LeadingZeroCount(ushort value) => (ushort)(BitOperations.LeadingZeroCount(value) - 16); 285public static ushort PopCount(ushort value) => (ushort)BitOperations.PopCount(value); 294public static ushort TrailingZeroCount(ushort value) => (ushort)(BitOperations.TrailingZeroCount(value << 16) - 16); 434public static bool IsPow2(ushort value) => BitOperations.IsPow2((uint)value); 437public static ushort Log2(ushort value) => (ushort)BitOperations.Log2(value);
src\libraries\System.Private.CoreLib\src\System\UInt32.cs (9)
296public static uint LeadingZeroCount(uint value) => (uint)BitOperations.LeadingZeroCount(value); 307uint log2 = (uint)BitOperations.Log2(value) + 1; 329public static uint PopCount(uint value) => (uint)BitOperations.PopCount(value); 333public static uint RotateLeft(uint value, int rotateAmount) => BitOperations.RotateLeft(value, rotateAmount); 337public static uint RotateRight(uint value, int rotateAmount) => BitOperations.RotateRight(value, rotateAmount); 341public static uint TrailingZeroCount(uint value) => (uint)BitOperations.TrailingZeroCount(value); 459int IBinaryInteger<uint>.GetShortestBitLength() => (sizeof(uint) * 8) - BitOperations.LeadingZeroCount(m_value); 498public static bool IsPow2(uint value) => BitOperations.IsPow2(value); 502public static uint Log2(uint value) => (uint)BitOperations.Log2(value);
src\libraries\System.Private.CoreLib\src\System\UInt64.cs (9)
295public static ulong LeadingZeroCount(ulong value) => (ulong)BitOperations.LeadingZeroCount(value); 304uint log2 = (uint)BitOperations.Log2(value) + 1; 336public static ulong PopCount(ulong value) => (ulong)BitOperations.PopCount(value); 340public static ulong RotateLeft(ulong value, int rotateAmount) => BitOperations.RotateLeft(value, rotateAmount); 344public static ulong RotateRight(ulong value, int rotateAmount) => BitOperations.RotateRight(value, rotateAmount); 348public static ulong TrailingZeroCount(ulong value) => (ulong)BitOperations.TrailingZeroCount(value); 466int IBinaryInteger<ulong>.GetShortestBitLength() => (sizeof(ulong) * 8) - BitOperations.LeadingZeroCount(m_value); 505public static bool IsPow2(ulong value) => BitOperations.IsPow2(value); 509public static ulong Log2(ulong value) => (ulong)BitOperations.Log2(value);
src\libraries\System.Private.CoreLib\src\System\UIntPtr.cs (8)
317public static nuint LeadingZeroCount(nuint value) => (nuint)BitOperations.LeadingZeroCount(value); 331public static nuint PopCount(nuint value) => (nuint)BitOperations.PopCount(value); 335public static nuint RotateLeft(nuint value, int rotateAmount) => BitOperations.RotateLeft(value, rotateAmount); 339public static nuint RotateRight(nuint value, int rotateAmount) => BitOperations.RotateRight(value, rotateAmount); 343public static nuint TrailingZeroCount(nuint value) => (nuint)BitOperations.TrailingZeroCount(value); 461int IBinaryInteger<nuint>.GetShortestBitLength() => (sizeof(nuint_t) * 8) - BitOperations.LeadingZeroCount(_value); 504public static bool IsPow2(nuint value) => BitOperations.IsPow2(value); 508public static nuint Log2(nuint value) => (nuint)BitOperations.Log2(value);
src\System\Runtime\CompilerServices\RuntimeHelpers.CoreCLR.cs (1)
511if (!BitOperations.IsPow2(alignment))
src\System\Runtime\CompilerServices\VirtualDispatchHelpers.cs (2)
25_hashCode = (int) ((uint)objectMethodTable + (BitOperations.RotateLeft((uint)classHandle, 5)) + (BitOperations.RotateRight((uint)methodHandle, 5)));
System.Private.Xml (11)
System\Xml\Schema\XsdDateTime.cs (4)
198Debug.Assert(BitOperations.IsPow2((uint)kinds), "One and only one DateTime type code can be set."); 201DateTimeTypeCode code = (DateTimeTypeCode)BitOperations.TrailingZeroCount((uint)kinds); 242Debug.Assert(BitOperations.IsPow2((uint)kinds), "Only one DateTime type code can be set."); 247DateTimeTypeCode code = (DateTimeTypeCode)BitOperations.TrailingZeroCount((uint)kinds);
System\Xml\Xsl\IlGen\XmlIlVisitor.cs (1)
3268if (!BitOperations.IsPow2((uint)kinds))
System\Xml\Xsl\XmlQueryTypeFactory.cs (3)
706if (BitOperations.IsPow2(kinds)) 708return ItemType.Create(s_nodeKindToTypeCode[BitOperations.TrailingZeroCount(kinds) + 1], false); 714members.Add(ItemType.Create(s_nodeKindToTypeCode[BitOperations.TrailingZeroCount(kinds) + 1], false));
System\Xml\Xsl\Xslt\CompilerScopeManager.cs (2)
149Debug.Assert(flag == (flag & ScopeFlags.ExclusiveFlags) && BitOperations.IsPow2((uint)flag), "One exclusive flag"); 168Debug.Assert(flag == (flag & ScopeFlags.InheritedFlags) && BitOperations.IsPow2((uint)flag), "one inherited flag");
System\Xml\Xsl\Xslt\MatcherBuilder.cs (1)
183if (!BitOperations.IsPow2((uint)nodeKinds))
System.Private.Xml.Linq (1)
System\Xml\Linq\XHashtable.cs (1)
147Debug.Assert(BitOperations.IsPow2(capacity), "capacity must be a power of 2");
System.Reflection.Metadata (5)
System\Reflection\Internal\Utilities\BitArithmetic.cs (2)
13Debug.Assert(BitOperations.PopCount(alignment) == 1); 27Debug.Assert(BitOperations.PopCount((uint)alignment) == 1);
System\Reflection\Metadata\Ecma335\MetadataSizes.cs (1)
444BitOperations.PopCount(ExternalTablesMask) * sizeof(int); // External row counts
System\Reflection\PortableExecutable\PEHeaderBuilder.cs (2)
67if (fileAlignment < 512 || fileAlignment > 64 * 1024 || BitOperations.PopCount((uint)fileAlignment) != 1) 72if (sectionAlignment < fileAlignment || BitOperations.PopCount((uint)sectionAlignment) != 1)
System.Runtime (1)
artifacts\obj\System.Runtime\Debug\net11.0\System.Runtime.Forwards.cs (1)
374[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.BitOperations))]
System.Runtime.Extensions (1)
System.Runtime.Extensions.cs (1)
53[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Numerics.BitOperations))]
System.Runtime.Numerics (31)
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\FormattingHelpers.CountDigits.cs (1)
112return (BitOperations.Log2(value) >> 2) + 1;
System\Number.BigInteger.cs (3)
1369maxIndex = BitOperations.Log2(scale1E9); 1438int fi = BitOperations.TrailingZeroCount(trailingPartialCount); 1447if ((BitOperations.PopCount((uint)trailingPartialCount) & 1) != 0)
System\Numerics\BigInteger.cs (22)
777return BitOperations.IsPow2(_sign); 786return BitOperations.IsPow2(_bits[iu]) && !_bits.AsSpan(0, iu).ContainsAnyExcept(0u); 999c = BitOperations.LeadingZeroCount(h); 1012c = BitOperations.LeadingZeroCount((uint)h); 1597int lzc = BitOperations.LeadingZeroCount(highLimb); 1603int lzc = BitOperations.LeadingZeroCount(~highLimb); 2047z = BitOperations.LeadingZeroCount(h); 2057z = BitOperations.LeadingZeroCount((uint)h); 3090BitOperations.LeadingZeroCount(highValue); 3192? BitOperations.LeadingZeroCount(value._bits[^1]) 3213result += (ulong)BitOperations.PopCount(part); 3229result += (ulong)BitOperations.PopCount(part); 3240result += (ulong)BitOperations.PopCount(part); 3260nuint rs = BitOperations.RotateLeft((nuint)value._sign, rotateAmount); 3281nuint rs = BitOperations.RotateRight((nuint)value._sign, rotateAmount); 3364result += (ulong)BitOperations.TrailingZeroCount(part); 3392return value >= 0 ? 32 - BitOperations.LeadingZeroCount((uint)value) : 33 - BitOperations.LeadingZeroCount(~(uint)value); 3399result += BigIntegerCalculator.BitsPerLimb - BitOperations.LeadingZeroCount(bits[^1]); 3414result += BigIntegerCalculator.BitsPerLimb + 1 - BitOperations.LeadingZeroCount(~part); 3631? (BigInteger)((BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount((nuint)value._sign | 1)) 3632: (BigInteger)(((long)value._bits.Length * BigIntegerCalculator.BitsPerLimb - 1) ^ BitOperations.LeadingZeroCount(value._bits[^1]));
System\Numerics\BigIntegerCalculator.DivRem.cs (1)
327int m = (int)BitOperations.RoundUpToPowerOf2((uint)right.Length / (uint)DivideBurnikelZieglerThreshold + 1);
System\Numerics\BigIntegerCalculator.GcdInv.cs (2)
332int z = BitOperations.LeadingZeroCount((uint)xh); 368int z = BitOperations.LeadingZeroCount(xh);
System\Numerics\BigIntegerCalculator.PowMod.cs (1)
619int trailingZeros = BitOperations.TrailingZeroCount(wValue);
System\Numerics\NumericsHelpers.cs (1)
54int cbitShift = BitOperations.LeadingZeroCount(man) - 11;
System.Security.Cryptography (2)
System\Security\Cryptography\RandomNumberGenerator.cs (2)
362if (BitOperations.IsPow2(choices.Length)) 394int mask = (int)BitOperations.RoundUpToPowerOf2((uint)choices.Length) - 1;
System.Text.Encodings.Web (2)
System\Text\Encodings\Web\DefaultHtmlEncoder.cs (2)
106int idxOfSemicolon = (int)((uint)BitOperations.Log2(scalarValue) / 4) + 4; 181int idxOfSemicolon = (int)((uint)BitOperations.Log2(scalarValue) / 4) + 4;
System.Text.RegularExpressions (2)
System\Text\RegularExpressions\RegexCharClass.cs (1)
1224return BitOperations.IsPow2(mask);
System\Text\RegularExpressions\Symbolic\SymbolicRegexMatcher.cs (1)
183_mintermsLog = BitOperations.Log2((uint)_minterms.Length) + 1;
System.Windows.Forms.Tests (2)
System\Windows\Forms\DragDropHelperTests.cs (2)
123bool isDragImageNull = BitOperations.LeadingZeroCount((uint)(nint)pDragImage->hbmpDragImage).Equals(32); 150bool isDragImageNull = BitOperations.LeadingZeroCount((uint)(nint)pDragImage->hbmpDragImage).Equals(32);
Test.Utilities (2)
src\Dependencies\Collections\Internal\ArraySortHelper.cs (1)
1269return BitOperations.Log2(value);
src\Dependencies\Collections\Internal\SegmentedArrayHelper.cs (1)
175return System.Numerics.BitOperations.Log2((uint)((Threshold / elementSize) - (2 * Unsafe.SizeOf<object>() + 8)));