1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-23 00:38:47 +00:00

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.
This commit is contained in:
Oliver Booth 2023-04-01 17:08:34 +01:00
parent b2a27cdafb
commit 677259b91c
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025
2 changed files with 3 additions and 2 deletions

View File

@ -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 - 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) using the [GetOffsetAndLength](https://learn.microsoft.com/en-us/dotnet/api/system.range.getoffsetandlength?view=net-7.0)
method. method.
- X10D: `Stream.ReadSingle(Endianness)` now returns a float instead of a double.
### Changed ### Changed

View File

@ -1,4 +1,4 @@
using System.Buffers.Binary; using System.Buffers.Binary;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security.Cryptography; using System.Security.Cryptography;
@ -345,7 +345,7 @@ public static class StreamExtensions
/// <param name="stream">The stream from which the value should be read.</param> /// <param name="stream">The stream from which the value should be read.</param>
/// <param name="endianness">The endian encoding to use.</param> /// <param name="endianness">The endian encoding to use.</param>
/// <returns>A single-precision floating point value read from the stream.</returns> /// <returns>A single-precision floating point value read from the stream.</returns>
public static double ReadSingle(this Stream stream, Endianness endianness) public static float ReadSingle(this Stream stream, Endianness endianness)
{ {
#if NET6_0_OR_GREATER #if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(stream); ArgumentNullException.ThrowIfNull(stream);