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

Bug: Shortest floating point representation: redundant trailing 0's #1873

Closed
AlbertoEAF opened this issue Sep 16, 2020 · 1 comment
Closed

Comments

@AlbertoEAF
Copy link

AlbertoEAF commented Sep 16, 2020

Hello,

I am using fmt::format to print numbers in several formats. One of them is floating point in shortest representation, but when numbers come out in scientific notation I sometimes have trailing 0's.

Original call
snprintf(buffer, buf_len, "%g", value)

New call
fmt::format("{:g}", value)

Up to now, writing many floating point numbers, all the mismatches I have are with the scientific notation and trailing zeros. This are some kinds of mismatches I'm having (red = original code output, green = new code output):
image

image

I know this seems "irrelevant" but it's enough to disturb LightGBM as is currently implemented.

Any suggestions? Am I calling something wrong? Is it supposed to happen?
(I really need this working this week, so I can for the time being do a pass over the output buffer and trim trailing 0's but let's say that's neither "fast" nor "the correct way").

Thank you!

@vitaut
Copy link
Contributor

vitaut commented Sep 17, 2020

Fixed in 7e68275, thanks for reporting!

@vitaut vitaut closed this as completed Sep 17, 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

No branches or pull requests

2 participants