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

:g does not behave as python for floating point numbers #126

Open
guibou opened this issue Jul 7, 2023 · 1 comment
Open

:g does not behave as python for floating point numbers #126

guibou opened this issue Jul 7, 2023 · 1 comment

Comments

@guibou
Copy link
Owner

guibou commented Jul 7, 2023

With PyF:

ghci> x = 1.0 :: Double
ghci> [fmt|{x}|]
"1.0"
ghci> [fmt|{x:g}|]
"1.000000"

In Python

>>> f"{1.0:g}"
'1'

That's convenient because it allows the user to trim the trailing 0 and . if any.

@eltix
Copy link

eltix commented Aug 26, 2024

@guibou Same issue for Rational:

ghci> [fmt|{(2::Rational):.2g}|]
"2.00"

Here, one would have expected "2" as a result

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