2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-05-06 11:32:59 +00:00
This commit is contained in:
Esiur Project 2023-10-24 17:33:35 +03:00
parent 8538a383a4
commit d6e223384c

View File

@ -565,11 +565,52 @@ public static class DC // Data Converter
}
public static int Mod(this int value, int divisor)
{
var rt = value % divisor;
if (rt < 0) return rt + divisor;
return rt;
}
public static ulong RotateLeft(this ulong value, int shift)
{
return value << shift | value >> (64 - shift);
}
public static ulong RotateRight(this ulong value, int shift)
{
return value >> shift | value << (64 - shift);
}
public static uint RotateLeft(this uint value, int shift)
{
return value << shift | value >> (32 - shift);
}
public static uint RotateRight(this uint value, int shift)
{
return value >> shift | value << (32 - shift);
}
public static ushort RotateLeft(this ushort value, int shift)
{
return (ushort)(value << shift | value >> (16 - shift));
}
public static ushort RotateRight(this ushort value, int shift)
{
return (ushort)(value >> shift | value << (16 - shift));
}
public static byte RotateLeft(this byte value, int shift)
{
return (byte)(value << shift | value >> (8 - shift));
}
public static byte RotateRight(this byte value, int shift)
{
return (byte)(value >> shift | value << (8 - shift));
}
public static byte GetUInt8(this byte[] data, uint offset)