-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<format>: fix std::format("{:#.precision}", floating)
#3815
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
Merged
Stephan T. Lavavej (StephanTLavavej)
merged 17 commits into
microsoft:main
from
achabense:_For_format
Jun 22, 2023
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d3d9307
'\0'->'e'
achabense 58ee368
std::format("{:#.5}", 1200) == "1200."
achabense e2fc2ec
Create env.lst
achabense 265bcb0
Add test.cpp
achabense 848a5f8
Update test.cpp
achabense 41d30b8
more tests
achabense d399cde
Delete env.lst
achabense 1942a43
Add files via upload
achabense d65c44b
Merge pull request #2 from achabense/_Fix_pr_formatting
achabense 48cab61
minor formatting
achabense b4e58b7
Update /env.lst
achabense 2d85863
relocate env.lst
achabense 4622f36
Rename test.cpp to test.cpp
achabense 9907efd
Merge pull request #3 from achabense/_relocation
achabense 0c75024
Update test.lst
achabense 1982fc1
Remove FAILs for some std/utilities/format/format.functions tests.
StephanTLavavej 75309ba
Remove unnecessary assignments.
StephanTLavavej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| RUNALL_INCLUDE ..\concepts_20_matrix.lst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| #include <cassert> | ||
| #include <format> | ||
|
|
||
| int main() { | ||
| assert(std::format("{:#.0}", 0.0) == "0."); | ||
| assert(std::format("{:#.1}", 0.0) == "0."); | ||
| assert(std::format("{:#.2}", 0.0) == "0."); | ||
|
|
||
| assert(std::format("{:#.0}", 1200.0) == "1.e+03"); | ||
| assert(std::format("{:#.1}", 1200.0) == "1.e+03"); | ||
| assert(std::format("{:#.2}", 1200.0) == "1.2e+03"); | ||
| assert(std::format("{:#.3}", 1200.0) == "1.2e+03"); | ||
| assert(std::format("{:#.4}", 1200.0) == "1200."); | ||
| assert(std::format("{:#.5}", 1200.0) == "1200."); | ||
| assert(std::format("{:#.6}", 1200.0) == "1200."); | ||
|
|
||
| assert(std::format("{:#.0}", 0.123) == "0.1"); | ||
| assert(std::format("{:#.1}", 0.123) == "0.1"); | ||
| assert(std::format("{:#.2}", 0.123) == "0.12"); | ||
| assert(std::format("{:#.3}", 0.123) == "0.123"); | ||
| assert(std::format("{:#.4}", 0.123) == "0.123"); | ||
| assert(std::format("{:#.5}", 0.123) == "0.123"); | ||
|
|
||
| assert(std::format("{:#.0}", 10.1) == "1.e+01"); | ||
| assert(std::format("{:#.1}", 10.1) == "1.e+01"); | ||
| assert(std::format("{:#.2}", 10.1) == "10."); | ||
| assert(std::format("{:#.3}", 10.1) == "10.1"); | ||
| assert(std::format("{:#.4}", 10.1) == "10.1"); | ||
| assert(std::format("{:#.5}", 10.1) == "10.1"); | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.