From 677259b91c216139b9b7323c96b5529abd3e14d0 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sat, 1 Apr 2023 17:08:34 +0100 Subject: [PATCH] fix: fixed Stream.ReadSingle returning wrong type ReadSingle previously returned a double, and this never failed unit tests since float -> double is a widening conversion, with values being comparable. --- CHANGELOG.md | 1 + X10D/src/IO/StreamExtensions.cs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96d9c140d..667e6ef26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -144,6 +144,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - X10D: `T[].Clear` will now correctly clear the specified range of elements by using the [GetOffsetAndLength](https://learn.microsoft.com/en-us/dotnet/api/system.range.getoffsetandlength?view=net-7.0) method. +- X10D: `Stream.ReadSingle(Endianness)` now returns a float instead of a double. ### Changed diff --git a/X10D/src/IO/StreamExtensions.cs b/X10D/src/IO/StreamExtensions.cs index edabeec4d..17611b89b 100644 --- a/X10D/src/IO/StreamExtensions.cs +++ b/X10D/src/IO/StreamExtensions.cs @@ -1,4 +1,4 @@ -using System.Buffers.Binary; +using System.Buffers.Binary; using System.Reflection; using System.Runtime.InteropServices; using System.Security.Cryptography; @@ -345,7 +345,7 @@ public static double ReadSingle(this Stream stream) /// The stream from which the value should be read. /// The endian encoding to use. /// A single-precision floating point value read from the stream. - public static double ReadSingle(this Stream stream, Endianness endianness) + public static float ReadSingle(this Stream stream, Endianness endianness) { #if NET6_0_OR_GREATER ArgumentNullException.ThrowIfNull(stream);