Rationale
Computing a Cyclic Redundancy Check (CRC) is a common algorithm used for error detection in things like networks or storage. Additionally, modern hardware provides instruction level support for computing these values. It would be beneficial if we exposed a set of general-purpose methods which allow iterative CRC32 computation.
Proposed API
namespace System.Numerics
{
public static class BitOperations
{
public static uint Crc32(uint crc, byte data);
public static uint Crc32(uint crc, ushort data);
public static uint Crc32(uint crc, uint data);
public static uint Crc32(uint crc, ulong data);
}
}
Open Questions
The output is generally treated as unsigned, however .NET considers unsigned integers (other than byte) as non-CLS compliant. It would be possible to expose both versions (those that take/return int and those that take/return uint). It would likewise be good on the input data to determine if they should be signed, unsigned, or both.
Rationale
Computing a Cyclic Redundancy Check (CRC) is a common algorithm used for error detection in things like networks or storage. Additionally, modern hardware provides instruction level support for computing these values. It would be beneficial if we exposed a set of general-purpose methods which allow iterative CRC32 computation.
Proposed API
Open Questions
The output is generally treated as unsigned, however .NET considers unsigned integers (other than byte) as non-CLS compliant. It would be possible to expose both versions (those that take/return
intand those that take/returnuint). It would likewise be good on the input data to determine if they should be signed, unsigned, or both.