diff --git a/X10D/src/IO/DecimalExtensions.cs b/X10D/src/IO/DecimalExtensions.cs index 8058f70..5b82682 100644 --- a/X10D/src/IO/DecimalExtensions.cs +++ b/X10D/src/IO/DecimalExtensions.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.Contracts; +using System.Diagnostics.Contracts; using System.Runtime.InteropServices; namespace X10D.IO; @@ -97,15 +97,22 @@ public static class DecimalExtensions #else Span buffer = stackalloc byte[16]; MemoryMarshal.Write(buffer, ref value); + WriteBits(destination, buffer); +#endif + } + private static void WriteBits(Span destination, Span buffer) + { var flags = MemoryMarshal.Read(buffer[..4]); var hi = MemoryMarshal.Read(buffer[4..8]); var lo = MemoryMarshal.Read(buffer[8..]); - destination[0] = flags; - destination[1] = hi; - destination[2] = (int)(lo & 0xFFFFFFFF); - destination[3] = (int)(lo >> 32); -#endif + var low = (uint)lo; + var mid = (uint)(lo >> 32); + + destination[0] = (int)low; + destination[1] = (int)mid; + destination[2] = hi; + destination[3] = flags; } }