Skip to content

Commit

Permalink
Fix Double.NegativeZero (#87364)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyoxZ authored Jun 12, 2023
1 parent eb65022 commit 4315b52
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libraries/System.Runtime/ref/System.Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2190,7 +2190,7 @@ public DivideByZeroException(string? message, System.Exception? innerException)
public const double MinValue = -1.7976931348623157E+308;
public const double NaN = 0.0 / 0.0;
public const double NegativeInfinity = -1.0 / 0.0;
public const double NegativeZero = -0;
public const double NegativeZero = -0.0;
public const double Pi = 3.141592653589793;
public const double PositiveInfinity = 1.0 / 0.0;
public const double Tau = 6.283185307179586;
Expand Down Expand Up @@ -4879,7 +4879,7 @@ public SerializableAttribute() { }
public const float MinValue = -3.4028235E+38f;
public const float NaN = 0.0f / 0.0f;
public const float NegativeInfinity = -1.0f / 0.0f;
public const float NegativeZero = -0f;
public const float NegativeZero = -0.0f;
public const float Pi = 3.1415927f;
public const float PositiveInfinity = 1.0f / 0.0f;
public const float Tau = 6.2831855f;
Expand Down
6 changes: 6 additions & 0 deletions src/libraries/System.Runtime/tests/System/DoubleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ public static void NegativeInfinity()
Assert.Equal(0xFFF00000_00000000u, BitConverter.DoubleToUInt64Bits(double.NegativeInfinity));
}

[Fact]
public static void NegativeZero()
{
Assert.Equal(0x80000000_00000000u, BitConverter.DoubleToUInt64Bits(double.NegativeZero));
}

public static IEnumerable<object[]> Parse_Valid_TestData()
{
NumberStyles defaultStyle = NumberStyles.Float | NumberStyles.AllowThousands;
Expand Down
6 changes: 6 additions & 0 deletions src/libraries/System.Runtime/tests/System/SingleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ public static void NegativeInfinity()
Assert.Equal(0xFF800000u, BitConverter.SingleToUInt32Bits(float.NegativeInfinity));
}

[Fact]
public static void NegativeZero()
{
Assert.Equal(0x80000000u, BitConverter.SingleToUInt32Bits(float.NegativeZero));
}

public static IEnumerable<object[]> Parse_Valid_TestData()
{
NumberStyles defaultStyle = NumberStyles.Float | NumberStyles.AllowThousands;
Expand Down

0 comments on commit 4315b52

Please sign in to comment.