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

Wrong output for fixed-precision floating-point format #1917

Closed
jk-jeon opened this issue Oct 5, 2020 · 1 comment
Closed

Wrong output for fixed-precision floating-point format #1917

jk-jeon opened this issue Oct 5, 2020 · 1 comment

Comments

@jk-jeon
Copy link
Contributor

jk-jeon commented Oct 5, 2020

Please look at the following code:

#include <iostream>
#define FMT_HEADER_ONLY 1
#include "fmt/format.h"

int main () {
 std::cout << fmt::format("{:.1e}", 1e-34);
}

The output of the code is

1.00e-34

but the expected output is

1.0e-34

So fmt is putting one more 0. The same is happening when the precision is set to larger values. It seems that this issue only happens for certain floating-point inputs.

@vitaut
Copy link
Contributor

vitaut commented Oct 7, 2020

Good catch, thanks. Fixed in a18b3fb.

@vitaut vitaut closed this as completed Oct 7, 2020
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 a pull request may close this issue.

2 participants