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

Controlling fixed precision for logging float point values #775

Merged
merged 2 commits into from
Oct 8, 2024

Conversation

davidhjp01
Copy link
Contributor

CSV files printed from file_observer does not include enough decimal places in case for logging latitude and longitude values for a ship vessel. Added a method cosim::file_observer::file_observer_config::fixed_precision(const int) to specify fixed precision value for file_observer.

if (precision_ > -1) {
ss.precision(defaultPrecision);
ss << times << "," << stepCount;
ss.precision(precision_);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a way to avoid setting precision twice pr. sample is to use two string writers, one for custom & one for default precision. Then at the end should be able to just go fsw_ << ss_default.rdbuf() << ss_custom.rdbuf();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each line will have time & stepCount so don't think we can concatenate at once after the loop.

@davidhjp01 davidhjp01 merged commit 5c6e196 into master Oct 8, 2024
20 checks passed
@davidhjp01 davidhjp01 deleted the floating_point_format branch October 8, 2024 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants