diff --git a/src/de.rs b/src/de.rs index 7cc9f9b8e..a2f34b908 100644 --- a/src/de.rs +++ b/src/de.rs @@ -434,8 +434,8 @@ impl<'de, R: Read<'de>> Deserializer { } else { let neg = (significand as i64).wrapping_neg(); - // Convert into a float if we underflow. - if neg > 0 { + // Convert into a float if we underflow, or on `-0`. + if neg >= 0 { ParserNumber::F64(-(significand as f64)) } else { ParserNumber::I64(neg) diff --git a/tests/test.rs b/tests/test.rs index 9fdf26cc7..d6a0e81c1 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -805,6 +805,7 @@ fn test_parse_u64() { #[test] fn test_parse_negative_zero() { for negative_zero in &[ + "-0", "-0.0", "-0e2", "-0.0e2",