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

strformat float printing doesn't print ".0" portion [regression] #11089

Closed
kaushalmodi opened this issue Apr 22, 2019 · 5 comments

Comments

Projects
None yet
3 participants
@kaushalmodi
Copy link
Contributor

commented Apr 22, 2019

Earlier strformat printed a float 1.0 as "1.0". Now it prints just "1".

It was nice to have that ".0" portion printed that gave a clarity that the value being printed was a float.

Example

import strformat

let
  foo: float = 1.0
  bar: float = 1.5
echo fmt"{foo}" # Prints "1" -- bad
echo fmt"{bar}" # Prints "1.5" -- good

Current Output

1
1.5

Expected Output

1.0
1.5

Possible Solution

Additional Information

$ nim -v
Nim Compiler Version 0.19.9 [Linux: amd64]
Compiled at 2019-04-22
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: 4f9366975441be889a8cd4fbfb4e41f6830dc542
active boot switches: -d:release

/cc @Araq @krux02


I discovered as I was rerunning all the snippets in my Nim notes with the latest devel. git diff highlighted all the missing ".0"'s:

image

@Araq Araq added the Regression label Apr 23, 2019

@Araq

This comment has been minimized.

Copy link
Member

commented Apr 23, 2019

This was never explicitly in the program though as far as I know. Did your libc change?

@mratsim mratsim added the Stdlib label Apr 23, 2019

@kaushalmodi

This comment has been minimized.

Copy link
Contributor Author

commented Apr 23, 2019

Hmm, I definitely haven't updated my libc (glibc that ships with the OS, right?). My OS version is still RHEL 6.8.

Are you not able to reproduce the same ".0" truncation?

@kaushalmodi

This comment has been minimized.

Copy link
Contributor Author

commented Apr 23, 2019

@Araq The regression of this behavior from stable to devel was confirmed on IRC.

Ref: https://irclogs.nim-lang.org/23-04-2019.html#07:01:10

@kaushalmodi

This comment has been minimized.

Copy link
Contributor Author

commented Apr 23, 2019

If it helps trace down this problem, in my git diff, I had also noticed the resolution reduction when printing floats in general too. Printing 1.23456789 printed something like 1.23456 instead. I can share the exact examples when I get to my PC.

@Araq Araq closed this in 8d206b2 Apr 23, 2019

@kaushalmodi

This comment has been minimized.

Copy link
Contributor Author

commented Apr 23, 2019

@Araq Thank you for that quick fix! As I was past this regression fixes and evaluating other blocks in my notes, I ended up with #11092.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.