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
Closed

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

kaushalmodi opened this issue Apr 22, 2019 · 5 comments

Comments

@kaushalmodi
Copy link
Contributor

kaushalmodi 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
Copy link
Member

Araq commented Apr 23, 2019

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

@kaushalmodi
Copy link
Contributor Author

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
Copy link
Contributor Author

@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
Copy link
Contributor Author

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 as completed in 8d206b2 Apr 23, 2019
@kaushalmodi
Copy link
Contributor Author

@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
Projects
None yet
Development

No branches or pull requests

3 participants