You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i have a requirement where i don't want json library to round the values of double datatype. Is there we can prevent it ?
e.g.
when i call "json.dump" function on my double variable "Amount" it gets rounded values instead of actual values.
The Actual value Amount = 2555.5599999999999 gets rounded to 2555.56
The Actual value Amount = 2527.7800000000002 gets rounded to 2527.78
I have implemented "to_json" function for the above structure.
in the main function , i do following.
main()
{
PaymentInfo Pay_obj ;
Pay_obj.Amount = 2555.5599999999999;
Pay_obj.Currency = "USD";
json json_obj = Pay_obj;
std:: stringstream output;
output << json_obj.dump(); // after this statement the value of Amount gets rounded to 2555.56.
// i want to retain the original value as it is. is there a way we can to
// it.
}
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stalebot
added
the
state: stale
the issue has not been updated in a while and will be closed automatically soon unless it is updated
label
May 24, 2019
nlohmann
removed
the
state: stale
the issue has not been updated in a while and will be closed automatically soon unless it is updated
label
Jun 21, 2019
i have a requirement where i don't want json library to round the values of double datatype. Is there we can prevent it ?
e.g.
when i call "json.dump" function on my double variable "Amount" it gets rounded values instead of actual values.
is there any way we can stop rounding ?
code looks like
struct PaymentInfo
{
double Amount;
std:string Currency ;
};
I have implemented "to_json" function for the above structure.
in the main function , i do following.
main()
{
PaymentInfo Pay_obj ;
Pay_obj.Amount = 2555.5599999999999;
Pay_obj.Currency = "USD";
json json_obj = Pay_obj;
std:: stringstream output;
output << json_obj.dump(); // after this statement the value of Amount gets rounded to 2555.56.
// i want to retain the original value as it is. is there a way we can to
// it.
}
The text was updated successfully, but these errors were encountered: