Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative zero is not preserved #289

Closed
erikfroseth opened this issue Apr 10, 2015 · 0 comments
Closed

Negative zero is not preserved #289

erikfroseth opened this issue Apr 10, 2015 · 0 comments
Labels
Milestone

Comments

@erikfroseth
Copy link
Contributor

Given a negative zero as input, the negative sign is silently truncated. It should be preserved.

  const char* json = "{\"negative\": -0.0, \"positive\": 0.0}";
  rapidjson::Document d;
  d.Parse(json);

  rapidjson::StringBuffer buffer;
  rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
  d.Accept(writer);

  // Outputs {"negative":0.0,"positive":0.0}
  std::cout << buffer.GetString() << std::endl;

This also happens to integers, but I'm not sure how that should be handled. The javascript spec is quite clear that negative and positive zero should be distinguished, but most programming languages does not differentiate between -(int)0 and +(int)0.

@miloyip miloyip added the bug label Apr 10, 2015
@miloyip miloyip added this to the v1.0 milestone Apr 10, 2015
@miloyip miloyip closed this as completed Apr 10, 2015
miloyip added a commit that referenced this issue Apr 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants