mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 23:25:43 +00:00
fix: fix incorrect endian swap
This commit is contained in:
parent
ed46bcd0d8
commit
caa0070458
@ -48,11 +48,11 @@ public static class DoubleExtensions
|
|||||||
#else
|
#else
|
||||||
if (BitConverter.IsLittleEndian)
|
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 value);
|
||||||
return MemoryMarshal.TryWrite(destination, ref tmp);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public static class DoubleExtensions
|
|||||||
#if NET5_0_OR_GREATER
|
#if NET5_0_OR_GREATER
|
||||||
return BinaryPrimitives.TryWriteDoubleLittleEndian(destination, value);
|
return BinaryPrimitives.TryWriteDoubleLittleEndian(destination, value);
|
||||||
#else
|
#else
|
||||||
if (!BitConverter.IsLittleEndian)
|
if (BitConverter.IsLittleEndian)
|
||||||
{
|
{
|
||||||
return MemoryMarshal.TryWrite(destination, ref value);
|
return MemoryMarshal.TryWrite(destination, ref value);
|
||||||
}
|
}
|
||||||
|
@ -50,11 +50,11 @@ public static class SingleExtensions
|
|||||||
#else
|
#else
|
||||||
if (BitConverter.IsLittleEndian)
|
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 value);
|
||||||
return MemoryMarshal.TryWrite(destination, ref tmp);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ public static class SingleExtensions
|
|||||||
#if NET5_0_OR_GREATER
|
#if NET5_0_OR_GREATER
|
||||||
return BinaryPrimitives.TryWriteSingleLittleEndian(destination, value);
|
return BinaryPrimitives.TryWriteSingleLittleEndian(destination, value);
|
||||||
#else
|
#else
|
||||||
if (!BitConverter.IsLittleEndian)
|
if (BitConverter.IsLittleEndian)
|
||||||
{
|
{
|
||||||
return MemoryMarshal.TryWrite(destination, ref value);
|
return MemoryMarshal.TryWrite(destination, ref value);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user