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

Change decimal formatting #3818

Merged
merged 2 commits into from
Oct 10, 2024
Merged

Change decimal formatting #3818

merged 2 commits into from
Oct 10, 2024

Conversation

lpugin
Copy link
Contributor

@lpugin lpugin commented Oct 8, 2024

The PR switches %.10g formatting decimal with a precision limited to 4 digits after the ..

[Changing my mind: using stringstream with no relevant figures limitation]

This applies to @tstamp or @tstamp2, for example, and avoids the trailing zeros. See previous discussions here and there

The output will be tstamp="1" or tstamp="1.75" instead of tstamp="1.0000" or tstamp="1.7500" respectively.

This implementation avoids the use of stringstream, which I find over the top. It sets an arbitrary limit to 10 significant numbers - if the value is larger that 999,999, then the number of digits after the . will be reduced. We can adjust the value (or even change to stringstream) if a case where the loss would have an impact can be identified, but this looks quite unrealistic to me.

Copy link
Contributor

@rettinghaus rettinghaus left a comment

Choose a reason for hiding this comment

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

Looks familiar

@lpugin
Copy link
Contributor Author

lpugin commented Oct 8, 2024

Looks familiar

Yes... actually maybe switching to stringstream might be better and solve this issue once for all

Copy link
Contributor

@rettinghaus rettinghaus left a comment

Choose a reason for hiding this comment

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

Looks fine, thanks.

@lpugin lpugin requested a review from ahankinson October 9, 2024 07:55
@ahankinson ahankinson merged commit 528bdb9 into develop Oct 10, 2024
9 checks passed
@lpugin lpugin deleted the develop-decimal-formatting branch October 10, 2024 19:38
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.

3 participants