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_printOutput: 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::bigintorsemantic_tag::bigdecwith abigint_chars_format::numberoption, viz:Output:
It's arguable that that should be the default, as you suggest, that would be more consistent.
bigint_formatandbigint_chars_formatwould also have been better namedbignum_formatandb…