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

Interpolating float into string with too large of a width returns unexpected result #13210

Closed
dsemi opened this issue Jan 19, 2022 · 1 comment · Fixed by #22244
Closed

Interpolating float into string with too large of a width returns unexpected result #13210

dsemi opened this issue Jan 19, 2022 · 1 comment · Fixed by #22244
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@dsemi
Copy link

dsemi commented Jan 19, 2022

V version: 0.2.4 d826317
OS: Linux

What did you do?

n := 0.1
println('${n:36.2f}')
println('${n:37.2f}')
println('${n:38.2f}')

What did you expect to see?

                               0.10
                                0.10
                                 0.10
                                  0.10

What did you see instead?

                               0.10
                                 .10
                                   10
                                     0

After a certain point, the padding character starts to overwrite the formatted float value and corrupt the expected output. I can't reproduce this with integers, just floats.
I think this is likely related to the hardcoded length 32 output buffer in format_fl; the tipping point where the bug starts to appear is at 32 + '0.10'.len + 1.

@dsemi dsemi added the Bug This tag is applied to issues which reports bugs. label Jan 19, 2022
@dumblob
Copy link
Contributor

dumblob commented Jan 24, 2022

There are problems with printing of floats etc. for more than a year - see discussion #11855 (comment) .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants