Add Swap32

This commit is contained in:
Ac_K 2018-06-17 06:06:30 +02:00 committed by GitHub
parent ac5e0b23b6
commit 5f5cfd4a82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,5 +3,14 @@
static class EndianSwap
{
public static short Swap16(short Value) => (short)(((Value >> 8) & 0xff) | (Value << 8));
public static int Swap32(int Value)
{
uint UintVal = (uint)Value;
return (int)(((UintVal >> 24) & 0x000000ff) |
((UintVal >> 8) & 0x0000ff00) |
((UintVal << 8) & 0x00ff0000) |
((UintVal << 24) & 0xff000000));
}
}
}