Skip to content

Commit

Permalink
fix: fixed Stream.ReadSingle returning wrong type
Browse files Browse the repository at this point in the history
ReadSingle previously returned a double, and this never failed unit tests since float -> double is a widening conversion, with values being comparable.
  • Loading branch information
oliverbooth committed Apr 1, 2023
1 parent b2a27cd commit 677259b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions 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;
Expand Down Expand Up @@ -345,7 +345,7 @@ public static double ReadSingle(this Stream stream)
/// <param name="stream">The stream from which the value should be read.</param>
/// <param name="endianness">The endian encoding to use.</param>
/// <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
ArgumentNullException.ThrowIfNull(stream);
Expand Down

0 comments on commit 677259b

Please sign in to comment.