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

User-defined double output precision #3

Closed
wants to merge 3 commits into from
Closed

Conversation

pah
Copy link
Owner

@pah pah commented Apr 2, 2014

Writing a double to an OutputStream current prints at most 6 significant
digits (according to the C standard).

The functions Set/GetDoublePrecision(), added to the Writer classes
can be used to fluently set the precision, i.e. the number of significant
digits to use for writing the double:

  Writer<...> writer(...);
  d.Accept(writer.SetDoublePrecision(12)); // print up to 12 significant digits

Additionally, a new Double(double,int) overload is added to the Writer classes,
allowing to programmatically write a single double value with a custom output precision:

writer.StartArray()
    .Double(1.2345) // == Double(..., writer.GetDoublePrecision())
    .Double(1.2345678,9) // explicit precision
    .EndArray();

An additional unit test Writer.DoublePrecision is added as well.
See upstream issues

pah added 3 commits February 28, 2014 13:57
Writing a double to an OutputStream current prints at most 6 significant
digits (according to the C standard).

The function SetDoublePrecision(), added to the Writer classes
can be used to fluently set the precision, i.e. the number of
significant digits to use for writing the double:

  Writer<...> writer(...);
  d.Accept(writer.SetDoublePrecision(12));
As proposed in other patches, it is convenient to pass a user-defined
precision for the (programmatic) output of a single double value
to an OutputStream.

This patch adds an additional overload with an explicit precision
argument to the (Pretty)Writer class templates.
@pah pah added the enhancement label Apr 2, 2014
@pah pah self-assigned this Apr 2, 2014
@pah pah added the upstream label Apr 2, 2014
@pah
Copy link
Owner Author

pah commented Apr 2, 2014

Merged into local for-upstream/master branch via 2ce917d.
Kept open here to track upstream status.

@pah
Copy link
Owner Author

pah commented Jun 25, 2014

See upstream pull-request Tencent/rapidjson#19.

@pah
Copy link
Owner Author

pah commented Jun 26, 2014

Merged upstream.

@pah pah closed this Jun 26, 2014
pah added a commit that referenced this pull request Aug 11, 2014
This drops #3 and #4, as their functionality has been superseded
upstream, see Tencent/rapidjson#97 and Tencent/rapidjson#101.

Conflicts:
	include/rapidjson/prettywriter.h
	include/rapidjson/reader.h
	include/rapidjson/writer.h
@pah pah deleted the double-precision branch August 12, 2014 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant