Skip to content

Commit

Permalink
Apply comments
Browse files Browse the repository at this point in the history
  • Loading branch information
d.paranichev committed Jan 31, 2024
1 parent d72d6b0 commit 1ffe5fa
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1130,11 +1130,17 @@ public static void Equal(Half expected, Half actual, Half variance)
/// <exception cref="EqualException">Thrown when the representations are not identical</exception>
public static void Equal(double expected, double actual)
{
if (BitConverter.DoubleToInt64Bits(expected) == BitConverter.DoubleToInt64Bits(actual))
if (BitConverter.ToInt64(BitConverter.GetBytes(expected)) == BitConverter.ToInt64(BitConverter.GetBytes(actual)))
{
return;
}

if (PlatformDetection.IsRiscV64Process && double.IsNaN(expected) && double.IsNaN(actual))
{
// RISC-V does not preserve payload
return;
}

throw EqualException.ForMismatchedValues(ToStringPadded(expected), ToStringPadded(actual));
}

Expand All @@ -1144,7 +1150,7 @@ public static void Equal(double expected, double actual)
/// <exception cref="EqualException">Thrown when the representations are not identical</exception>
public static void Equal(float expected, float actual)
{
if (BitConverter.SingleToInt32Bits(expected) == BitConverter.SingleToInt32Bits(actual))
if (BitConverter.ToInt32(BitConverter.GetBytes(expected)) == BitConverter.ToInt32(BitConverter.GetBytes(actual)))
{
return;
}
Expand All @@ -1165,7 +1171,7 @@ public static void Equal(float expected, float actual)
/// <exception cref="EqualException">Thrown when the representations are not identical</exception>
public static void Equal(Half expected, Half actual)
{
if (BitConverter.HalfToUInt16Bits(expected) == BitConverter.HalfToUInt16Bits(actual))
if (BitConverter.ToInt16(BitConverter.GetBytes(expected)) == BitConverter.ToInt16(BitConverter.GetBytes(actual)))
{
return;
}
Expand Down

0 comments on commit 1ffe5fa

Please sign in to comment.