-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
YAML Floating Point Precision in Output Files #1016
Comments
Sure
…On Wed, Jul 28, 2021 at 3:03 AM holdsworth ***@***.***> wrote:
When saving a file with new API you cannot set explicitly the number of
digits after the . thus when having a double of the form 1.0 it is saved as
1, which causes issues later on if you're deducing parameter type based on
input, this badly hurts the config file (especially when you re-save it)
The fix would be to modify the last else in inner_encode function (line
102 in node/convert.h file) from stream << ... to stream <<
std::setprecision(12) << std::fixed << rhs;
Note that you can expose the set precision to be externally modified,
would you like me to send a PR?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1016>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAICUBWXIE7ZK2AOLRH3WKLTZ62WRANCNFSM5BD2CIQA>
.
|
@jbeder we have been blocked by this problem for a long time. besides i am new for yaml-cpp, could you give us a clue how to address this issue? |
I think the OP was going to submit PR? Anyways, patches welcome. |
I am not sure who OP is, but with suggested code, i tried with fujitatomoya/ros2_persist_parameter_server#13 (comment) but it did not work. it would be appreciated if you can tell me i got anything wrong. |
When saving a file with new API you cannot set explicitly the number of digits after the . thus when having a double of the form 1.0 it is saved as 1, which causes issues later on if you're deducing parameter type based on input, this badly hurts the config file (especially when you re-save it)
The fix would be to modify the last else in inner_encode function (line 102 in node/convert.h file) from stream << ... to stream << std::setprecision(12) << std::fixed << rhs;
Note that you can expose the set precision to be externally modified, would you like me to send a PR?
The text was updated successfully, but these errors were encountered: