Skip to content

Commit 98cafd1

Browse files
committed
Clarify "is negative zero" check
1 parent 53310f7 commit 98cafd1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

dotnet/src/webdriver/BiDi/Communication/Json/Converters/BiDiDoubleConverter.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ public override void Write(Utf8JsonWriter writer, double value, JsonSerializerOp
8383

8484
static bool IsNegativeZero(double x)
8585
{
86-
const long NegativeZeroBits = -9223372036854775808;
86+
// Negative zero is less trivial to test, because 0 == -0 is true
87+
// We need to do a bit pattern comparison
8788

88-
return BitConverter.DoubleToInt64Bits(x) == NegativeZeroBits;
89+
return BitConverter.DoubleToInt64Bits(x) == BitConverter.DoubleToInt64Bits(-0.0);
8990
}
9091
}
9192
}

0 commit comments

Comments
 (0)