Skip to content

Commit d86e353

Browse files
authored
Merge pull request #801 from dtolnay/negative0
Parse -0 as float -0.0 instead of integer 0
2 parents b419f2e + 51a4db1 commit d86e353

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/de.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,8 @@ impl<'de, R: Read<'de>> Deserializer<R> {
434434
} else {
435435
let neg = (significand as i64).wrapping_neg();
436436

437-
// Convert into a float if we underflow.
438-
if neg > 0 {
437+
// Convert into a float if we underflow, or on `-0`.
438+
if neg >= 0 {
439439
ParserNumber::F64(-(significand as f64))
440440
} else {
441441
ParserNumber::I64(neg)

tests/test.rs

+1
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ fn test_parse_u64() {
805805
#[test]
806806
fn test_parse_negative_zero() {
807807
for negative_zero in &[
808+
"-0",
808809
"-0.0",
809810
"-0e2",
810811
"-0.0e2",

0 commit comments

Comments
 (0)