diff --git a/src/BizHawk.Client.Common/tools/RamSearchEngine/Extensions.cs b/src/BizHawk.Client.Common/tools/RamSearchEngine/Extensions.cs index e186fddeea..14ff056127 100644 --- a/src/BizHawk.Client.Common/tools/RamSearchEngine/Extensions.cs +++ b/src/BizHawk.Client.Common/tools/RamSearchEngine/Extensions.cs @@ -6,12 +6,6 @@ namespace BizHawk.Client.Common.RamSearchEngine { internal static class Extensions { - public static float ToFloat(this long val) - { - var bytes = BitConverter.GetBytes((int)val); - return BitConverter.ToSingle(bytes, 0); - } - public static IEnumerable ToBytes(this IEnumerable addresses, SearchEngineSettings settings) => settings.IsDetailed() ? addresses.ToDetailedBytes(settings.Domain) diff --git a/src/BizHawk.Client.Common/tools/RamSearchEngine/RamSearchEngine.cs b/src/BizHawk.Client.Common/tools/RamSearchEngine/RamSearchEngine.cs index 7ad70d5704..c5139a033e 100644 --- a/src/BizHawk.Client.Common/tools/RamSearchEngine/RamSearchEngine.cs +++ b/src/BizHawk.Client.Common/tools/RamSearchEngine/RamSearchEngine.cs @@ -12,10 +12,10 @@ namespace BizHawk.Client.Common.RamSearchEngine { public class RamSearchEngine { - /// TODO move to BizHawk.Common private static float ReinterpretAsF32(long l) { - return Unsafe.As(ref l); + var lsw = unchecked((uint) l); + return Unsafe.As(ref lsw); } private Compare _compareTo = Compare.Previous; diff --git a/src/BizHawk.Tests/Common/ConversionTests.cs b/src/BizHawk.Tests/Common/ConversionTests.cs deleted file mode 100644 index c05d5c5662..0000000000 --- a/src/BizHawk.Tests/Common/ConversionTests.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Buffers.Binary; -using System.Runtime.CompilerServices; - -namespace BizHawk.Tests.Common; - -// test for RamSearchEngine.ReinterpretAsF32 -[TestClass] -public class ConversionTests -{ - private static float ReinterpretAsF32Unsafe(long l) - { - return Unsafe.As(ref l); - } - - private static readonly byte[] ScratchSpace = new byte[8]; - - private static float ReinterpretAsF32BitConverter(long l) - { - BinaryPrimitives.WriteInt64LittleEndian(ScratchSpace, l); - return BitConverter.ToSingle(ScratchSpace, startIndex: 0); - } - - [TestMethod] - [DoNotParallelize] // old implementation is not thread safe - [DataRow(0, 0)] - [DataRow(1, 1.401298E-45F)] - [DataRow(1109917696, 42)] - [DataRow(1123477881, 123.456F)] - [DataRow(3212836864, -1)] - [DataRow(0x7fffffffbf800000, -1)] - public void TestReinterpretAsF32(long input, float expected) - { - float f32BitConverter = ReinterpretAsF32BitConverter(input); - float f32Unsafe = ReinterpretAsF32Unsafe(input); - - Assert.AreEqual(expected, f32BitConverter); - Assert.AreEqual(expected, f32Unsafe); - } -}