mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 23:25:43 +00:00
Fix endianness reversal for float/double
This commit is contained in:
parent
e6a858c7e7
commit
f2ed6aebce
@ -58,7 +58,8 @@ public static class DoubleExtensions
|
||||
{
|
||||
if (BitConverter.IsLittleEndian == (endianness == Endianness.BigEndian))
|
||||
{
|
||||
value = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value));
|
||||
long tmp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value));
|
||||
value = BitConverter.Int64BitsToDouble(tmp);
|
||||
}
|
||||
|
||||
return MemoryMarshal.TryWrite(destination, ref value);
|
||||
|
@ -58,7 +58,8 @@ public static class SingleExtensions
|
||||
{
|
||||
if (BitConverter.IsLittleEndian == (endianness == Endianness.BigEndian))
|
||||
{
|
||||
value = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value));
|
||||
int tmp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value));
|
||||
value = BitConverter.Int32BitsToSingle(tmp);
|
||||
}
|
||||
|
||||
return MemoryMarshal.TryWrite(destination, ref value);
|
||||
|
@ -173,7 +173,8 @@ public static class StreamExtensions
|
||||
|
||||
if (BitConverter.IsLittleEndian == (endianness == Endianness.BigEndian))
|
||||
{
|
||||
value = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value));
|
||||
long tmp = BinaryPrimitives.ReverseEndianness(BitConverter.DoubleToInt64Bits(value));
|
||||
value = BitConverter.Int64BitsToDouble(tmp);
|
||||
}
|
||||
|
||||
return value;
|
||||
@ -374,7 +375,8 @@ public static class StreamExtensions
|
||||
|
||||
if (BitConverter.IsLittleEndian == (endianness == Endianness.BigEndian))
|
||||
{
|
||||
value = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value));
|
||||
int tmp = BinaryPrimitives.ReverseEndianness(BitConverter.SingleToInt32Bits(value));
|
||||
value = BitConverter.Int32BitsToSingle(tmp);
|
||||
}
|
||||
|
||||
return value;
|
||||
|
Loading…
Reference in New Issue
Block a user