1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-22 00:38:48 +00:00

fix: fix incorrect endian swap

This commit is contained in:
Oliver Booth 2023-08-23 16:43:33 +01:00
parent ed46bcd0d8
commit caa0070458
Signed by: oliverbooth
GPG Key ID: B89D139977693FED
2 changed files with 8 additions and 8 deletions

View File

@ -48,11 +48,11 @@ public static class DoubleExtensions
#else
if (BitConverter.IsLittleEndian)
{
return MemoryMarshal.TryWrite(destination, ref value);
long tmp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value));
return MemoryMarshal.TryWrite(destination, ref tmp);
}
long tmp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value));
return MemoryMarshal.TryWrite(destination, ref tmp);
return MemoryMarshal.TryWrite(destination, ref value);
#endif
}
@ -67,7 +67,7 @@ public static class DoubleExtensions
#if NET5_0_OR_GREATER
return BinaryPrimitives.TryWriteDoubleLittleEndian(destination, value);
#else
if (!BitConverter.IsLittleEndian)
if (BitConverter.IsLittleEndian)
{
return MemoryMarshal.TryWrite(destination, ref value);
}

View File

@ -50,11 +50,11 @@ public static class SingleExtensions
#else
if (BitConverter.IsLittleEndian)
{
return MemoryMarshal.TryWrite(destination, ref value);
int tmp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value));
return MemoryMarshal.TryWrite(destination, ref tmp);
}
int tmp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value));
return MemoryMarshal.TryWrite(destination, ref tmp);
return MemoryMarshal.TryWrite(destination, ref value);
#endif
}
@ -69,7 +69,7 @@ public static class SingleExtensions
#if NET5_0_OR_GREATER
return BinaryPrimitives.TryWriteSingleLittleEndian(destination, value);
#else
if (!BitConverter.IsLittleEndian)
if (BitConverter.IsLittleEndian)
{
return MemoryMarshal.TryWrite(destination, ref value);
}