-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Open
Labels
api-ready-for-reviewAPI is ready for review, it is NOT ready for implementationAPI is ready for review, it is NOT ready for implementationarea-System.Numerics
Description
Background and motivation
This is defined and used a few places in the runtime and libs: https://github.com/search?q=repo%3Adotnet%2Fruntime%20ReverseBits&type=code
It would be generally useful to expose it publicly in BitOperations.
This operation can be hardware accelerated on Arm64 (rbit) and recent x86/64 (GFNI or AVX512_BMM).
API Proposal
namespace System.Numerics;
public static class BitOperations
{
public static byte ReverseBits(byte value);
public static ushort ReverseBits(ushort value);
public static uint ReverseBits(uint value);
public static ulong ReverseBits(ulong value);
public static nuint ReverseBits(nuint value);
}API Usage
uint xrev = BitOperations.ReverseBits(x);Alternative Designs
Could consider signed and/or smaller type overloads
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-ready-for-reviewAPI is ready for review, it is NOT ready for implementationAPI is ready for review, it is NOT ready for implementationarea-System.Numerics