Skip to content

Commit

Permalink
Merge pull request #801 from dtolnay/negative0
Browse files Browse the repository at this point in the history
Parse -0 as float -0.0 instead of integer 0
  • Loading branch information
dtolnay committed Sep 14, 2021
2 parents b419f2e + 51a4db1 commit d86e353
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/de.rs
Expand Up @@ -434,8 +434,8 @@ impl<'de, R: Read<'de>> Deserializer<R> {
} 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)
Expand Down
1 change: 1 addition & 0 deletions tests/test.rs
Expand Up @@ -805,6 +805,7 @@ fn test_parse_u64() {
#[test]
fn test_parse_negative_zero() {
for negative_zero in &[
"-0",
"-0.0",
"-0e2",
"-0.0e2",
Expand Down

0 comments on commit d86e353

Please sign in to comment.