Output multiprecision as a number instead of a string #565
-
There is an example of how to read multiprecision number from a Json. The example below demonstrates the behavior:
the output is:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Beta Was this translation helpful? Give feedback.
-
Apologies, I think I misunderstood your question! You can output a string tagged with std::string s = "[100000000000000000000000000000000.1234]";
auto options = json_options{}
.lossless_number(true)
.bigint_format(bigint_chars_format::number);
json j = json::parse(s, options);
std::cout << print(j,options) << "\n"; // or pretty_print Output:
It's arguable that that should be the default, as you suggest, that would be more consistent. |
Beta Was this translation helpful? Give feedback.
-
Yes, I confirm this |
Beta Was this translation helpful? Give feedback.
Apologies, I think I misunderstood your question!
You can output a string tagged with
semantic_tag::bigint
orsemantic_tag::bigdec
with abigint_chars_format::number
option, viz:Output:
It's arguable that that should be the default, as you suggest, that would be more consistent.
bigint_format
andbigint_chars_format
would also have been better namedbignum_format
andb…