This commit is contained in:
Lani Aung
2024-09-25 20:01:32 -06:00
parent d39e73a6fa
commit 94ab274246
10 changed files with 146 additions and 59 deletions
@@ -6,7 +6,7 @@ internal static class EndianUtility
{
public static int ToLittleEndian(this ReadOnlySpan<byte> bytes)
{
var x = BitConverter.ToInt32(bytes);
var x = bytes.Length == 2 ? BitConverter.ToInt16(bytes) : BitConverter.ToInt32(bytes);
return BitConverter.IsLittleEndian ? x : BinaryPrimitives.ReverseEndianness(x);
}