mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 02:45:41 +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))
|
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);
|
return MemoryMarshal.TryWrite(destination, ref value);
|
||||||
|
@ -58,7 +58,8 @@ public static class SingleExtensions
|
|||||||
{
|
{
|
||||||
if (BitConverter.IsLittleEndian == (endianness == Endianness.BigEndian))
|
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);
|
return MemoryMarshal.TryWrite(destination, ref value);
|
||||||
|
@ -173,7 +173,8 @@ public static class StreamExtensions
|
|||||||
|
|
||||||
if (BitConverter.IsLittleEndian == (endianness == Endianness.BigEndian))
|
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;
|
return value;
|
||||||
@ -374,7 +375,8 @@ public static class StreamExtensions
|
|||||||
|
|
||||||
if (BitConverter.IsLittleEndian == (endianness == Endianness.BigEndian))
|
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;
|
return value;
|
||||||
|
Loading…
Reference in New Issue
Block a user