libexpr/print: Require decimal point on float printing. #14784
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Fixes #3077 .
Context
Tracking down the weird behavior of current nix (per the issue), we see:
I looked around for a while and realized this was probably happening over in the repl code, so I looked for CYAN and found
printFloatover insrc/libexpr/print.cc.The original code:
Now, iostreams by default don't show the decimal point, so we have to force it (after saving the flags):
This has the desired effect, mostly:
Unfortunately, the question of "how do we get this to show the correct decimal precision?" is a bit open-ended.
The open question is:
4.0000renders as4.0.4.0renders as4.00000...but so does4.000001.4.00000000000004displays as4.00000000000004but some larger one eventually rounds. If it rounds to all zeros, should that be truncated as well?There's some test problems as well, but those are less important than this core formatting question.
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.